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