Module: Quaff::Utils
- Defined in:
- lib/utils.rb
Overview
:nodoc:
Class Method Summary collapse
- .local_ip ⇒ Object
- .new_branch ⇒ Object
- .new_call_id ⇒ Object
- .paramhash_to_str(params) ⇒ Object
- .pid ⇒ Object
Class Method Details
.local_ip ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/utils.rb', line 7 def Utils.local_ip addrs = System.get_ifaddrs if addrs.empty? "0.0.0.0" elsif (addrs.size == 1) addrs[0][:inet_addr] else addrs.select {|k, v| k != :lo}.shift[1][:inet_addr] end end |
.new_branch ⇒ Object
26 27 28 |
# File 'lib/utils.rb', line 26 def Utils.new_branch "z9hG4bK#{Time.new.to_f}" end |
.new_call_id ⇒ Object
22 23 24 |
# File 'lib/utils.rb', line 22 def Utils.new_call_id "#{pid}_#{Time.new.to_i}@#{local_ipv4}" end |
.paramhash_to_str(params) ⇒ Object
30 31 32 |
# File 'lib/utils.rb', line 30 def Utils.paramhash_to_str params params.collect {|k, v| if (v == true) then ";#{k}" else ";#{k}=#{v}" end}.join("") end |
.pid ⇒ Object
18 19 20 |
# File 'lib/utils.rb', line 18 def Utils.pid Process.pid end |