Class: TPPlus::Nodes::IONode

Inherits:
Object
  • Object
show all
Defined in:
lib/tp_plus/nodes/io_node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, id) ⇒ IONode

Returns a new instance of IONode.



5
6
7
8
9
# File 'lib/tp_plus/nodes/io_node.rb', line 5

def initialize(type, id)
  @type    = type
  @id      = id.to_i
  @comment = ""
end

Instance Attribute Details

#commentObject

Returns the value of attribute comment.



4
5
6
# File 'lib/tp_plus/nodes/io_node.rb', line 4

def comment
  @comment
end

Instance Method Details

#eval(context, options = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/tp_plus/nodes/io_node.rb', line 19

def eval(context, options={})
  s = result

  if options[:disable_mixed_logic]
    s = "#{s}=ON"
  end

  options[:force_parens] ? "(#{s})" : s
end

#requires_mixed_logic?(context) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/tp_plus/nodes/io_node.rb', line 11

def requires_mixed_logic?(context)
  ["F","SO","SI","DI"].include?(@type) ? true : false
end

#resultObject



15
16
17
# File 'lib/tp_plus/nodes/io_node.rb', line 15

def result
  "#{@type}[#{@id}:#{@comment}]"
end