Class: TinyClassifier::Input
- Inherits:
-
Object
- Object
- TinyClassifier::Input
- Defined in:
- lib/tiny-classifier/input.rb
Instance Method Summary collapse
- #given? ⇒ Boolean
-
#initialize(data = nil) ⇒ Input
constructor
A new instance of Input.
- #read ⇒ Object
Constructor Details
#initialize(data = nil) ⇒ Input
Returns a new instance of Input.
18 19 20 |
# File 'lib/tiny-classifier/input.rb', line 18 def initialize(data = nil) @data = data end |
Instance Method Details
#given? ⇒ Boolean
22 23 24 25 |
# File 'lib/tiny-classifier/input.rb', line 22 def given? return true if @data or $stdin.is_a?(StringIO) File.pipe?(STDIN) end |
#read ⇒ Object
27 28 29 |
# File 'lib/tiny-classifier/input.rb', line 27 def read @data ||= $stdin.readlines.join(" ").strip end |