Class: BioTable::TableRow
- Inherits:
-
Object
- Object
- BioTable::TableRow
- Defined in:
- lib/bio-table/tablerow.rb
Overview
Abstraction of a parsed table row
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#rowname ⇒ Object
readonly
Returns the value of attribute rowname.
Instance Method Summary collapse
- #all_fields ⇒ Object
- #all_valid? ⇒ Boolean
- #append(values) ⇒ Object
-
#initialize(rowname, fields = []) ⇒ TableRow
constructor
A new instance of TableRow.
- #match_all_fields?(zip) ⇒ Boolean
- #valid? ⇒ Boolean
Constructor Details
#initialize(rowname, fields = []) ⇒ TableRow
Returns a new instance of TableRow.
6 7 8 9 |
# File 'lib/bio-table/tablerow.rb', line 6 def initialize rowname, fields = [] @rowname = rowname @fields = fields end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
5 6 7 |
# File 'lib/bio-table/tablerow.rb', line 5 def fields @fields end |
#rowname ⇒ Object (readonly)
Returns the value of attribute rowname.
5 6 7 |
# File 'lib/bio-table/tablerow.rb', line 5 def rowname @rowname end |
Instance Method Details
#all_fields ⇒ Object
15 16 17 |
# File 'lib/bio-table/tablerow.rb', line 15 def all_fields ([@rowname] << @fields).flatten end |
#all_valid? ⇒ Boolean
19 20 21 |
# File 'lib/bio-table/tablerow.rb', line 19 def all_valid? all_fields != nil and all_fields.size > 0 end |
#append(values) ⇒ Object
11 12 13 |
# File 'lib/bio-table/tablerow.rb', line 11 def append values @fields += values end |
#match_all_fields?(zip) ⇒ Boolean
27 28 29 30 31 32 33 34 35 |
# File 'lib/bio-table/tablerow.rb', line 27 def match_all_fields? zip row_fields = all_fields zip.each do | a | index = a[0] value = a[1] return false if row_fields[index] != value end true end |
#valid? ⇒ Boolean
23 24 25 |
# File 'lib/bio-table/tablerow.rb', line 23 def valid? fields != nil and fields.size > 0 end |