Class: InputReader::Builder
- Inherits:
-
Object
- Object
- InputReader::Builder
- Defined in:
- lib/input_reader/input_reader.rb
Instance Attribute Summary collapse
-
#input ⇒ Object
readonly
Returns the value of attribute input.
Instance Method Summary collapse
- #get_input ⇒ Object
-
#initialize(options = nil) ⇒ Builder
constructor
A new instance of Builder.
Constructor Details
#initialize(options = nil) ⇒ Builder
Returns a new instance of Builder.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/input_reader/input_reader.rb', line 6 def initialize( = nil) ||= {} @prompt = [:prompt] @allow_blank = [:allow_blank] @default_value = [:default_value] @valid_values = Array.wrap([:valid_values]) @validators = Array.wrap([:validators]) @pre_validators = Array.wrap([:pre_validators]) @post_validators = Array.wrap([:post_validators]) @parsers = Array.wrap([:parsers]) end |
Instance Attribute Details
#input ⇒ Object (readonly)
Returns the value of attribute input.
4 5 6 |
# File 'lib/input_reader/input_reader.rb', line 4 def input @input end |
Instance Method Details
#get_input ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/input_reader/input_reader.rb', line 19 def get_input begin print "#{@prompt} " flush rescue Exception => e puts e. + e.class.inspect exit end while !valid_input? @input end |