Module: Arduino::OptionParser
Instance Method Summary collapse
- #parse(options) ⇒ Object
- #raise_if_no_board(options) ⇒ Object
- #rename_key(options, from, to) ⇒ Object
- #upcase_keys(options) ⇒ Object
Instance Method Details
#parse(options) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/arduino-mk/option_parser.rb', line 2 def parse() = .dup raise_if_no_board() rename_key(, :board, :BOARD_TAG) rename_key(, :port, :ARDUINO_PORT) upcase_keys() end |
#raise_if_no_board(options) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/arduino-mk/option_parser.rb', line 15 def raise_if_no_board() unless [:board] = "Please specifiy your board in the initializer." += "\n\nArduino.boards will give you a list of valid boards." raise ArgumentError, end end |
#rename_key(options, from, to) ⇒ Object
30 31 32 |
# File 'lib/arduino-mk/option_parser.rb', line 30 def rename_key(, from, to) [to] = .delete(from) if [from] end |
#upcase_keys(options) ⇒ Object
24 25 26 27 28 |
# File 'lib/arduino-mk/option_parser.rb', line 24 def upcase_keys() .keys.each do |k| rename_key(, k, k.upcase) end end |