Class: OSCAccess::EmittableProperty

Inherits:
Object
  • Object
show all
Defined in:
lib/osc-access/emittable_property.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(subject, pattern, options = {}) ⇒ EmittableProperty

Returns a new instance of EmittableProperty.



8
9
10
11
12
13
14
# File 'lib/osc-access/emittable_property.rb', line 8

def initialize(subject, pattern, options = {})
  @subject = subject
  @pattern = pattern
  @arg = options[:arg]
  @translate = options[:translate]
  @action = options[:action]
end

Instance Attribute Details

#action ⇒ Object (readonly)

Returns the value of attribute action.



6
7
8
# File 'lib/osc-access/emittable_property.rb', line 6

def action
  @action
end

#arg ⇒ Object (readonly)

Returns the value of attribute arg.



6
7
8
# File 'lib/osc-access/emittable_property.rb', line 6

def arg
  @arg
end

#pattern ⇒ Object (readonly)

Returns the value of attribute pattern.



6
7
8
# File 'lib/osc-access/emittable_property.rb', line 6

def pattern
  @pattern
end

#subject ⇒ Object (readonly)

Returns the value of attribute subject.



6
7
8
# File 'lib/osc-access/emittable_property.rb', line 6

def subject
  @subject
end

Instance Method Details

#translated(target_obj) ⇒ Object



24
25
26
27
# File 'lib/osc-access/emittable_property.rb', line 24

def translated(target_obj)        
  raw_val = value(target_obj)
  @translate.nil? ? raw_val : Translate.using(raw_val, @translate, :to_local => false)  
end

#value(target_obj) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/osc-access/emittable_property.rb', line 16

def value(target_obj)
  val = case @subject
    when Proc then @subject.call(target_obj)
    when Symbol then target_obj.send(@subject)
  end
  [val].flatten   
end