Class: TPPlus::Nodes::IONode

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseNode

#can_be_inlined?

Constructor Details

#initialize(type, id) ⇒ IONode

Returns a new instance of IONode.



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

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

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

Instance Method Details

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



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

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)


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

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

#resultObject



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

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