Class: TabularData::Reader
- Inherits:
-
Object
- Object
- TabularData::Reader
- Defined in:
- lib/tabular_data.rb
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Reader
constructor
A new instance of Reader.
- #read(entry, attributes_to_parse, &block) ⇒ Object
- #strategy ⇒ Object
- #strategy=(str) ⇒ Object
Constructor Details
#initialize(attributes) ⇒ Reader
Returns a new instance of Reader.
79 80 81 |
# File 'lib/tabular_data.rb', line 79 def initialize(attributes) @attributes = attributes end |
Instance Method Details
#read(entry, attributes_to_parse, &block) ⇒ Object
83 84 85 86 |
# File 'lib/tabular_data.rb', line 83 def read(entry, attributes_to_parse, &block) strategy.call(entry, attributes_to_parse, @attributes, &block) entry end |
#strategy ⇒ Object
64 65 66 |
# File 'lib/tabular_data.rb', line 64 def strategy @strategy ||= TabularData::Strategies::CSVStrategy.new end |
#strategy=(str) ⇒ Object
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/tabular_data.rb', line 68 def strategy=(str) if str.is_a? Symbol case str when :csv then @strategy = TabularData::Strategies::CSVStrategy.new when :array then @strategy = TabularData::Strategies::ArrayStrategy.new end else @strategy = str end end |