Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/netlinx/erb/helpers.rb
Overview
:nodoc:
Other collapse
-
#remove_comma_after_last_item ⇒ Object
Intended for initializing struct constants.
-
#to_hiqnet(sv = nil) ⇒ Object
Convert a string to a HiQnet address struct.
Instance Method Details
#remove_comma_after_last_item ⇒ Object
Intended for initializing struct constants.
368 369 370 |
# File 'lib/netlinx/erb/helpers.rb', line 368 def remove_comma_after_last_item self.gsub(/(?<=\}),(.*?)\z/, ' \1') end |
#to_hiqnet(sv = nil) ⇒ Object
Convert a string to a HiQnet address struct.
Can include state variable.
380 381 382 383 384 385 386 387 |
# File 'lib/netlinx/erb/helpers.rb', line 380 def to_hiqnet sv = nil sv ||= '' sv = sv.is_a?(Fixnum) ? sv.to_s(16) : sv.to_s sv = sv.rjust(4, '0') unless sv.empty? address = self + sv "{#{address.gsub(/\A0x/, '').upcase.scan(/../).map {|s| '$' + s}.join(', ')}}," end |