Class: Layout

Inherits:
Object
  • Object
show all
Defined in:
lib/baa_chan/layout.rb

Constant Summary collapse

LAYOUTS_PATH =
'lib/baa_chan/layouts'

Instance Method Summary collapse

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

#attributesObject



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

#lineObject



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_prefixObject



24
25
26
# File 'lib/baa_chan/layout.rb', line 24

def trade_prefix
  attributes['trades']['prefix']
end