Class: Finexclub::Signal

Inherits:
Object
  • Object
show all
Includes:
Document
Defined in:
lib/finexclub/signal.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Document

included

Constructor Details

#initialize(core, meta = {}) ⇒ Signal

Returns a new instance of Signal.



6
7
8
9
# File 'lib/finexclub/signal.rb', line 6

def initialize(core, meta = {})
  @core = core
  apply_meta(meta)
end

Instance Attribute Details

#coreObject (readonly)

Returns the value of attribute core.



4
5
6
# File 'lib/finexclub/signal.rb', line 4

def core
  @core
end

Class Method Details

.build(core, signal_type, params) ⇒ Object



18
19
20
21
22
# File 'lib/finexclub/signal.rb', line 18

def build(core, signal_type, params)
  signal = handler_for(signal_type).new(core)
  signal.build(params)
  signal
end

.handler_for(signal_type) ⇒ Object



12
13
14
15
16
# File 'lib/finexclub/signal.rb', line 12

def handler_for(signal_type)
  #class_name = signal_type.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
  class_name = signal_type.to_s.gsub(/^(.)/) { $1.upcase }
  Finexclub::Signals.const_get(class_name)
end