Class: ECG::Context

Inherits:
Object
  • Object
show all
Includes:
Plugin::LoadFileValues, Plugin::LoadOptionValues, Singleton
Defined in:
lib/ecg/context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Plugin::LoadOptionValues

prepended

Constructor Details

#initializeContext

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

#parserObject (readonly)

Returns the value of attribute parser.



14
15
16
# File 'lib/ecg/context.rb', line 14

def parser
  @parser
end

#targetsObject (readonly)

Returns the value of attribute targets.



14
15
16
# File 'lib/ecg/context.rb', line 14

def targets
  @targets
end

#valuesObject (readonly)

Returns the value of attribute values.



14
15
16
# File 'lib/ecg/context.rb', line 14

def values
  @values
end

Instance Method Details

#bindingObject



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

Returns:

  • (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_modeObject



39
40
41
# File 'lib/ecg/context.rb', line 39

def trim_mode
  @parser.trim_mode
end