Class: Totango::ArgParser
- Inherits:
-
Object
- Object
- Totango::ArgParser
- Defined in:
- lib/totango/arg_parser.rb
Class Attribute Summary collapse
-
.named_args ⇒ Object
readonly
Returns the value of attribute named_args.
Class Method Summary collapse
Instance Method Summary collapse
Class Attribute Details
.named_args ⇒ Object (readonly)
Returns the value of attribute named_args.
6 7 8 |
# File 'lib/totango/arg_parser.rb', line 6 def named_args @named_args end |
Class Method Details
.parse(args) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/totango/arg_parser.rb', line 8 def parse(args) new.tap do |parser| args.each do |arg, val| param = registered_args[arg] param = custom_param_name(arg) unless param parser[param] = val end end end |
Instance Method Details
#[](arg) ⇒ Object
65 66 67 |
# File 'lib/totango/arg_parser.rb', line 65 def [](arg) values_hash[arg] end |
#[]=(arg, val) ⇒ Object
69 70 71 |
# File 'lib/totango/arg_parser.rb', line 69 def []=(arg, val) values_hash[arg] = val end |
#to_params ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/totango/arg_parser.rb', line 57 def to_params args = (ArgParser.named_args + values_hash.keys).uniq args.map do |arg| [arg, CGI.escape(self[arg].to_s)].join("=") if arg && self[arg] end.compact.join("&") end |
#values_hash ⇒ Object
53 54 55 |
# File 'lib/totango/arg_parser.rb', line 53 def values_hash @__values_hash__ ||= {} end |