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.
378 379 380 |
# File 'lib/netlinx/erb/helpers.rb', line 378 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.
390 391 392 393 394 395 396 397 |
# File 'lib/netlinx/erb/helpers.rb', line 390 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 |