Class: LadderConverter::KvCode

Inherits:
PlcCode
  • Object
show all
Defined in:
lib/ladder_converter/kv_code.rb

Instance Attribute Summary

Attributes inherited from PlcCode

#devices, #mnemonic

Instance Method Summary collapse

Methods inherited from PlcCode

#add_device, #device

Constructor Details

#initialize(mnemonic, devices) ⇒ KvCode

Returns a new instance of KvCode.



8
9
10
11
12
13
14
# File 'lib/ladder_converter/kv_code.rb', line 8

def initialize mnemonic, devices
  super
  case self.mnemonic
  when 'LABEL'
    @devices = [own_device(mnemonic)]
  end
end

Instance Method Details

#becone_subroutin_labelObject



16
17
18
# File 'lib/ladder_converter/kv_code.rb', line 16

def becone_subroutin_label
  @mnemonic = 'SBN'
end

#to_sObject



20
21
22
23
# File 'lib/ladder_converter/kv_code.rb', line 20

def to_s
  return mnemonic if devices.empty?
  ([mnemonic] + devices).join(" ")
end