Class: ParameterParser

Inherits:
Object
  • Object
show all
Defined in:
lib/pinkoi/parameter_parser.rb

Overview

this class takes care of parsing the parameters creating url

Instance Method Summary collapse

Constructor Details

#initializeParameterParser

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_uriObject



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

#usageObject



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