Class: Parse::Input
- Inherits:
-
Object
- Object
- Parse::Input
- Defined in:
- lib/parse/input.rb
Instance Method Summary collapse
- #[](name) ⇒ Object
-
#initialize(path, separator = $/, &init) ⇒ Input
constructor
A new instance of Input.
- #method_missing(method, *args, &block) ⇒ Object
Constructor Details
#initialize(path, separator = $/, &init) ⇒ Input
Returns a new instance of Input.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/parse/input.rb', line 10 def initialize( path, separator = $/, &init ) @path = path @separator = separator @state = :read @_pre_readers = Array.new @_readers = Array.new @_post_readers = Array.new @_skip_starters = Array.new @_skip_stoppers = Array.new @_skips = Array.new @_skip_searches = Array.new @_stops = Array.new instance_eval(&init) unless init.nil? parse end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/parse/input.rb', line 38 def method_missing( method, *args, &block ) variable_name = "@#{method}" if instance_variables.include? variable_name instance_variable_get(variable_name) else super end end |
Instance Method Details
#[](name) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/parse/input.rb', line 29 def []( name ) variable_name = "@#{name}" if instance_variables.include? variable_name instance_variable_get(variable_name) else nil end end |