Class: CodeMiner::ExpressionContainer
- Inherits:
-
Expression
- Object
- Expression
- CodeMiner::ExpressionContainer
- Defined in:
- lib/codeminer/expressions/expression_container.rb
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Attributes inherited from Expression
#args, #block, #delimiter, #src, #token
Class Method Summary collapse
Instance Method Summary collapse
- #add(exp) ⇒ Object
- #each ⇒ Object
-
#initialize(body, type, src = nil) ⇒ ExpressionContainer
constructor
A new instance of ExpressionContainer.
Methods inherited from Expression
Methods included from SourceExtract::Usage
#adjust_src, #column, #column=, #end_column, #end_column=, #end_line, #end_line=, #line, #line=, #src, #src_extract
Constructor Details
#initialize(body, type, src = nil) ⇒ ExpressionContainer
Returns a new instance of ExpressionContainer.
16 17 18 19 20 |
# File 'lib/codeminer/expressions/expression_container.rb', line 16 def initialize(body, type, src=nil) @body = body @type = type @src = src end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
5 6 7 |
# File 'lib/codeminer/expressions/expression_container.rb', line 5 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
5 6 7 |
# File 'lib/codeminer/expressions/expression_container.rb', line 5 def value @value end |
Class Method Details
.wrap(exp, type) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/codeminer/expressions/expression_container.rb', line 7 def self.wrap(exp, type) if exp.kind_of?(ExpressionContainer) new(exp.each, type, exp.src_extract) else wrapped = exp.class == Array ? exp : [exp] new(wrapped, type, exp.src_extract) end end |
Instance Method Details
#add(exp) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/codeminer/expressions/expression_container.rb', line 26 def add(exp) if exp.kind_of?(ExpressionContainer) exp.each.each do |e| @body << e adjust_src(e.src_extract) end else @body << exp adjust_src(exp.src_extract) end self end |
#each ⇒ Object
22 23 24 |
# File 'lib/codeminer/expressions/expression_container.rb', line 22 def each @body end |