Class: PTT::DataRow
- Inherits:
-
Object
- Object
- PTT::DataRow
- Defined in:
- lib/ptt/data_row.rb
Instance Attribute Summary collapse
-
#num ⇒ Object
Returns the value of attribute num.
-
#record ⇒ Object
Returns the value of attribute record.
-
#state ⇒ Object
Returns the value of attribute state.
Instance Method Summary collapse
-
#initialize(orig, dataset) ⇒ DataRow
constructor
A new instance of DataRow.
- #method_missing(method) ⇒ Object
- #to_s ⇒ Object
- #to_s_attribute ⇒ Object
Constructor Details
#initialize(orig, dataset) ⇒ DataRow
Returns a new instance of DataRow.
7 8 9 10 11 12 13 |
# File 'lib/ptt/data_row.rb', line 7 def initialize(orig, dataset) @record = orig @num = dataset.index(orig) + 1 if defined? orig.current_state @state = orig.current_state end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method) ⇒ Object
15 16 17 18 |
# File 'lib/ptt/data_row.rb', line 15 def method_missing(method) str = @record.send(method).to_s str.respond_to?(:force_encoding) ? str.force_encoding('utf-8') : Iconv.iconv('UTF-8', 'UTF-8', str) end |
Instance Attribute Details
#num ⇒ Object
Returns the value of attribute num.
5 6 7 |
# File 'lib/ptt/data_row.rb', line 5 def num @num end |
#record ⇒ Object
Returns the value of attribute record.
5 6 7 |
# File 'lib/ptt/data_row.rb', line 5 def record @record end |
#state ⇒ Object
Returns the value of attribute state.
5 6 7 |
# File 'lib/ptt/data_row.rb', line 5 def state @state end |
Instance Method Details
#to_s ⇒ Object
20 21 22 |
# File 'lib/ptt/data_row.rb', line 20 def to_s @record.send(self.to_s_attribute) end |
#to_s_attribute ⇒ Object
24 25 26 |
# File 'lib/ptt/data_row.rb', line 24 def to_s_attribute @n.to_s end |