Class: Layout
- Inherits:
-
Object
- Object
- Layout
- Defined in:
- lib/baa_chan/layout.rb
Constant Summary collapse
- LAYOUTS_PATH =
'lib/baa_chan/layouts'
Instance Method Summary collapse
- #attributes ⇒ Object
- #index(attr_name = nil) ⇒ Object
-
#initialize(broker) ⇒ Layout
constructor
A new instance of Layout.
- #line ⇒ Object
- #regexp_for(attr) ⇒ Object
- #trade_prefix ⇒ Object
Constructor Details
#initialize(broker) ⇒ Layout
Returns a new instance of Layout.
6 7 8 |
# File 'lib/baa_chan/layout.rb', line 6 def initialize(broker) @broker = broker end |
Instance Method Details
#attributes ⇒ Object
10 11 12 |
# File 'lib/baa_chan/layout.rb', line 10 def attributes @attributes ||= YAML.safe_load(File.read(File.join(LAYOUTS_PATH, "#{@broker}.yml"))) end |
#index(attr_name = nil) ⇒ Object
18 19 20 21 22 |
# File 'lib/baa_chan/layout.rb', line 18 def index(attr_name = nil) attr = attr_name || caller_locations.first.label attributes[attr]['index'].to_i end |
#line ⇒ Object
14 15 16 |
# File 'lib/baa_chan/layout.rb', line 14 def line attributes[caller_locations.first.label]['line'].to_i end |
#regexp_for(attr) ⇒ Object
28 29 30 |
# File 'lib/baa_chan/layout.rb', line 28 def regexp_for(attr) attributes[attr]['regexp'] end |
#trade_prefix ⇒ Object
24 25 26 |
# File 'lib/baa_chan/layout.rb', line 24 def trade_prefix attributes['trades']['prefix'] end |