Class: BioTable::TableRow

Inherits:
Object
  • Object
show all
Defined in:
lib/bio-table/tablerow.rb

Overview

Abstraction of a parsed table row (validation mostly)

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#fieldsObject (readonly)

Returns the value of attribute fields.



5
6
7
# File 'lib/bio-table/tablerow.rb', line 5

def fields
  @fields
end

#rownameObject (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_fieldsObject



15
16
17
# File 'lib/bio-table/tablerow.rb', line 15

def all_fields
  ([@rowname] << @fields).flatten
end

#all_valid?Boolean

Returns:

  • (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

Returns:

  • (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

Returns:

  • (Boolean)


23
24
25
# File 'lib/bio-table/tablerow.rb', line 23

def valid?
  fields != nil and fields.size > 0
end