Module: LoraRb::Base
- Included in:
- LoraClient
- Defined in:
- lib/lora-rb/help.rb,
lib/lora-rb/utility.rb
Overview
It contains generic methods
Instance Method Summary collapse
- #lora_decode(payload) ⇒ Object
- #lora_encode(payload) ⇒ Object
-
#merge_tags_to_url(url, tags = {}, options = {}) ⇒ Object
Substitute tags with data into url.
Instance Method Details
#lora_decode(payload) ⇒ Object
22 23 24 |
# File 'lib/lora-rb/utility.rb', line 22 def lora_decode(payload) Base64.decode64(payload).unpack("H*").first end |
#lora_encode(payload) ⇒ Object
18 19 20 |
# File 'lib/lora-rb/utility.rb', line 18 def lora_encode(payload) Base64.encode64(payload.scan(/.{2}/).map { |b| b.to_i(16).chr }.join) end |
#merge_tags_to_url(url, tags = {}, options = {}) ⇒ Object
Substitute tags with data into url
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/lora-rb/utility.rb', line 7 def (url, ={}, ={}) url = url.dup puts "merge_tags_to_url: #{url}" if [:debug] == :full .each do |tag, value| puts " replace {#{tag}} with #{value}" if [:debug] == :full url.gsub!("{#{tag}}", value.to_s) end puts "merge_tags_to_url: completed #{url}" if [:debug] == :full url end |