Class: NRSER::Labs::LOTS::BoolOptConsumer
Instance Method Summary
collapse
Methods inherited from Consumer
#initialize
Instance Method Details
#can_consume?(tokens) ⇒ Boolean
105
106
107
108
109
110
111
112
113
|
# File 'lib/nrser/labs/lots/consumer.rb', line 105
def can_consume? tokens
return 0 unless consumed.empty?
first = tokens[0]
return 1 if self.switch_tokens.include?( tokens[0] )
return 0
end
|
#switch_tokens ⇒ Object
94
95
96
97
98
99
100
101
102
103
|
# File 'lib/nrser/labs/lots/consumer.rb', line 94
def switch_tokens
@switches ||= names.each_with_object( Set.new ) do |name, set|
if name.length == 1
set << "-#{ name }"
else
set << "--#{ name }"
set << "--no-#{ name }"
end
end
end
|