Class: Sijka::SijkaParser
- Inherits:
-
Object
- Object
- Sijka::SijkaParser
- Defined in:
- lib/sijka/parser.rb
Instance Method Summary collapse
-
#initialize(argv) ⇒ SijkaParser
constructor
A new instance of SijkaParser.
- #parse_flags ⇒ Object
- #parse_message ⇒ Object
Constructor Details
#initialize(argv) ⇒ SijkaParser
Returns a new instance of SijkaParser.
5 6 7 |
# File 'lib/sijka/parser.rb', line 5 def initialize(argv) @argv = argv end |
Instance Method Details
#parse_flags ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/sijka/parser.rb', line 9 def parse_flags = {} OptionParser.new do |opts| opts. = 'Usage: sijka [name] [-h] [-f sijkafile] [-l]' opts.on('-l', 'List available sijka files') do |_| ['list'] = true end opts.on('-f SIJKAFILE', 'Specify a sijka file') do |sijkafile| ['sijkafile'] = sijkafile end opts.on('-r', 'Random file') do |_| ['sijkafile'] = Sijka::FILE_LIST.sample end end.parse! end |
#parse_message ⇒ Object
26 27 28 |
# File 'lib/sijka/parser.rb', line 26 def @argv.any? ? @argv.join(' ') : '' end |