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 49 def initialize(options = {}, &block) 50 self.key = options[:key] 51 self.io = options.fetch(:io, self.class::DEFAULT_IO) 52 53 @auto_id_block = options.fetch(:auto_id, block) 54 @options = options 55 56 reset 57 end
Private Class Methods
file_method(method, mode, file, options = {}, *args, &block)
click to toggle source
# File lib/bismas/base.rb 38 def file_method(method, mode, file, options = {}, *args, &block) 39 Bismas.amend_encoding(options) 40 41 File.open_file(file, options, mode) { |io| 42 args.unshift(options.merge(io: io)) 43 method ? send(method, *args, &block) : block[new(*args)] 44 } 45 end
Public Instance Methods
reset()
click to toggle source
# File lib/bismas/base.rb 61 def reset 62 @auto_id = @auto_id_block ? @auto_id_block.call : default_auto_id 63 end
Private Instance Methods
default_auto_id(n = 0)
click to toggle source
# File lib/bismas/base.rb 67 def default_auto_id(n = 0) 68 lambda { n += 1 } 69 end