Class: ParameterParser
- Inherits:
-
Object
- Object
- ParameterParser
- Defined in:
- lib/pinkoi/parameter_parser.rb
Overview
this class takes care of parsing the parameters creating url
Instance Method Summary collapse
- #build_uri ⇒ Object
-
#initialize ⇒ ParameterParser
constructor
A new instance of ParameterParser.
- #usage ⇒ Object
Constructor Details
#initialize ⇒ ParameterParser
Returns a new instance of ParameterParser.
28 29 30 31 |
# File 'lib/pinkoi/parameter_parser.rb', line 28 def initialize @parameters = {} validate_args end |
Instance Method Details
#build_uri ⇒ Object
33 34 35 36 37 |
# File 'lib/pinkoi/parameter_parser.rb', line 33 def build_uri # create a string based on the parameters # assuming there was error check (big assumption for now) @parameters.map { |k, v| "#{k}=#{v}" }.join('&') end |
#usage ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/pinkoi/parameter_parser.rb', line 39 def usage 'Usage: pinkoi [options] --category=(int) --price=[int[,int]] --location=[US, JP, HK, CN, TW] --subcategory=(int) --material=(int[,int,int,...]) examples: pinkoi --category=1 --price=300 pinkoi --category=1 --price=0,100 pinkoi --category=1 --subcategory=205 --price=0,100' end |