Class: ECG::Context
- Inherits:
-
Object
- Object
- ECG::Context
- Includes:
- Plugin::LoadFileValues, Plugin::LoadOptionValues, Singleton
- Defined in:
- lib/ecg/context.rb
Instance Attribute Summary collapse
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
-
#targets ⇒ Object
readonly
Returns the value of attribute targets.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
- #binding ⇒ Object
-
#initialize ⇒ Context
constructor
A new instance of Context.
- #method_missing(name, *args, &block) ⇒ Object
- #respond_to_missing?(name, include_private = false) ⇒ Boolean
- #trim_mode ⇒ Object
Methods included from Plugin::LoadOptionValues
Constructor Details
#initialize ⇒ Context
Returns a new instance of Context.
16 17 18 19 20 |
# File 'lib/ecg/context.rb', line 16 def initialize @parser = OptionParser.instance @targets = { $stdin => $stdout } @values = Store.new end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/ecg/context.rb', line 27 def method_missing(name, *args, &block) if @values.respond_to?(name) @values.public_send(name, *args, &block) else super end end |
Instance Attribute Details
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
14 15 16 |
# File 'lib/ecg/context.rb', line 14 def parser @parser end |
#targets ⇒ Object (readonly)
Returns the value of attribute targets.
14 15 16 |
# File 'lib/ecg/context.rb', line 14 def targets @targets end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
14 15 16 |
# File 'lib/ecg/context.rb', line 14 def values @values end |
Instance Method Details
#binding ⇒ Object
22 23 24 25 |
# File 'lib/ecg/context.rb', line 22 def binding setup super # NOTE: Kernel.#binding is private end |
#respond_to_missing?(name, include_private = false) ⇒ Boolean
35 36 37 |
# File 'lib/ecg/context.rb', line 35 def respond_to_missing?(name, include_private = false) @values.respond_to?(name) || super end |
#trim_mode ⇒ Object
39 40 41 |
# File 'lib/ecg/context.rb', line 39 def trim_mode @parser.trim_mode end |