class Bismas::Base
Attributes
auto_id[RW]
io[RW]
key[RW]
Public Class Methods
new(options = {}, &block)
click to toggle source
# File lib/bismas/base.rb, line 49 def initialize(options = {}, &block) self.key = options[:key] self.io = options.fetch(:io, self.class::DEFAULT_IO) @auto_id_block = options.fetch(:auto_id, block) @options = options reset end
Private Class Methods
file_method(method, mode, file, options = {}, *args, &block)
click to toggle source
# File lib/bismas/base.rb, line 38 def file_method(method, mode, file, options = {}, *args, &block) Bismas.amend_encoding(options) File.open_file(file, options, mode) { |io| args.unshift(options.merge(io: io)) method ? send(method, *args, &block) : block[new(*args)] } end
Public Instance Methods
reset()
click to toggle source
# File lib/bismas/base.rb, line 61 def reset @auto_id = @auto_id_block ? @auto_id_block.call : default_auto_id end
Private Instance Methods
default_auto_id(n = 0)
click to toggle source
# File lib/bismas/base.rb, line 67 def default_auto_id(n = 0) lambda { n += 1 } end