Class: Glaemscribe::API::Charset::Swap
Instance Attribute Summary collapse
-
#line ⇒ Object
Returns the value of attribute line.
-
#targets ⇒ Object
Returns the value of attribute targets.
-
#trigger ⇒ Object
Returns the value of attribute trigger.
Instance Method Summary collapse
- #finalize(charset) ⇒ Object
- #has_target?(tname) ⇒ Boolean
-
#initialize(trigger, target_list) ⇒ Swap
constructor
A new instance of Swap.
Constructor Details
#initialize(trigger, target_list) ⇒ Swap
Returns a new instance of Swap.
38 39 40 41 42 43 |
# File 'lib/api/charset.rb', line 38 def initialize(trigger, target_list) @trigger = trigger @targets = {} @target_list = target_list end |
Instance Attribute Details
#line ⇒ Object
Returns the value of attribute line.
34 35 36 |
# File 'lib/api/charset.rb', line 34 def line @line end |
#targets ⇒ Object
Returns the value of attribute targets.
36 37 38 |
# File 'lib/api/charset.rb', line 36 def targets @targets end |
#trigger ⇒ Object
Returns the value of attribute trigger.
35 36 37 |
# File 'lib/api/charset.rb', line 35 def trigger @trigger end |
Instance Method Details
#finalize(charset) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/api/charset.rb', line 45 def finalize(charset) @lookup_table = {} trig = charset.n2c(@trigger) if !trig charset.errors << Glaeml::Error.new(@line, "Swap operator triggers #{@trigger} which does not exist in charset.") end @target_list.each{ |target_id| c = charset.n2c(target_id) if !c charset.errors << Glaeml::Error.new(@line, "Swap operator targets #{target_id} which does not exist in charset.") else c.names.each{ |n| @targets[n] = c } end } trig end |
#has_target?(tname) ⇒ Boolean
68 69 70 |
# File 'lib/api/charset.rb', line 68 def has_target?(tname) (@targets[tname] != nil) end |