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