Class: Codabel::File
- Inherits:
-
Object
- Object
- Codabel::File
- Defined in:
- lib/codabel/file.rb
Instance Attribute Summary collapse
-
#records ⇒ Object
readonly
Returns the value of attribute records.
Instance Method Summary collapse
- #<<(record) ⇒ Object
- #find_record(type) ⇒ Object
- #find_records(type) ⇒ Object
-
#initialize(records = []) ⇒ File
constructor
A new instance of File.
- #to_coda ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(records = []) ⇒ File
Returns a new instance of File.
3 4 5 |
# File 'lib/codabel/file.rb', line 3 def initialize(records = []) @records = records end |
Instance Attribute Details
#records ⇒ Object (readonly)
Returns the value of attribute records.
6 7 8 |
# File 'lib/codabel/file.rb', line 6 def records @records end |
Instance Method Details
#<<(record) ⇒ Object
8 9 10 |
# File 'lib/codabel/file.rb', line 8 def <<(record) @records << record end |
#find_record(type) ⇒ Object
16 17 18 |
# File 'lib/codabel/file.rb', line 16 def find_record(type) find_records(type).first end |
#find_records(type) ⇒ Object
12 13 14 |
# File 'lib/codabel/file.rb', line 12 def find_records(type) @records.select { |record| record.is_a?(type) } end |
#to_coda ⇒ Object
24 25 26 |
# File 'lib/codabel/file.rb', line 24 def to_coda with_actual_records.auto_enrich._validate!._to_coda end |
#validate! ⇒ Object
20 21 22 |
# File 'lib/codabel/file.rb', line 20 def validate! with_actual_records._validate! end |