Class: Sip::CmdOpts
- Inherits:
-
Hash
- Object
- Hash
- Sip::CmdOpts
- Defined in:
- lib/sip/cmdopts.rb
Instance Method Summary collapse
Instance Method Details
#set(*k) ⇒ Object
3 4 5 6 7 |
# File 'lib/sip/cmdopts.rb', line 3 def set(*k) k.each { |key| self[key] = nil } end |
#to_s(prefix = nil, suffix = nil) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/sip/cmdopts.rb', line 9 def to_s(prefix=nil, suffix=nil) opts = map { |k,v| if v.nil? (k.length > 1) ? "--#{k}" : "-#{k}" else (k.length > 1) ? "--#{k}=#{v}" : "-#{k} #{v}" end }.join(" ") [(prefix.nil? ? "" : prefix), opts, (suffix.nil? ? "" : suffix)].select { |v| v != "" }.join(" ") end |