Class: Bismas::Writer
Constant Summary collapse
- DEFAULT_IO =
$stdout
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
- #[]=(id, record) ⇒ Object
-
#initialize(options = {}) ⇒ Writer
constructor
A new instance of Writer.
- #put(record, *args) ⇒ Object (also: #<<)
- #write(records, *args) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(options = {}) ⇒ Writer
Returns a new instance of Writer.
51 52 53 54 55 56 57 58 59 |
# File 'lib/bismas/writer.rb', line 51 def initialize( = {}) @category_length = [:category_length] || DEFAULT_CATEGORY_LENGTH @padding_length = [:padding_length] || DEFAULT_PADDING_LENGTH @sort = [:sort] @chars = Bismas.chars() super end |
Class Method Details
.open(*args, &block) ⇒ Object
45 46 47 |
# File 'lib/bismas/writer.rb', line 45 def open(*args, &block) file_method(nil, 'wb', *args, &block) end |
.write(*args, &block) ⇒ Object
37 38 39 |
# File 'lib/bismas/writer.rb', line 37 def write(*args, &block) new(args., &block).write(*args) end |
.write_file(*args, &block) ⇒ Object
41 42 43 |
# File 'lib/bismas/writer.rb', line 41 def write_file(*args, &block) file_method(:write, 'wb', *args, &block) end |
Instance Method Details
#[]=(id, record) ⇒ Object
79 80 81 |
# File 'lib/bismas/writer.rb', line 79 def []=(id, record) write_i(id, record) end |
#put(record, *args) ⇒ Object Also known as: <<
69 70 71 72 73 74 75 |
# File 'lib/bismas/writer.rb', line 69 def put(record, *args) record.is_a?(Hash) ? write_i(nil, record, *args) : write_i(*args.unshift(*record)) self end |
#write(records, *args) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/bismas/writer.rb', line 61 def write(records, *args) !records.is_a?(Hash) ? records.each { |record| write_i(nil, record, *args) } : records.each { |id, record| write_i(id, record, *args) } self end |