Class: CodeMiner::ExpressionContainer

Inherits:
Expression
  • Object
show all
Defined in:
lib/codeminer/expressions/expression_container.rb

Instance Attribute Summary collapse

Attributes inherited from Expression

#args, #block, #delimiter, #src, #token

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Expression

not_implemented

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

#typeObject (readonly)

Returns the value of attribute type.



5
6
7
# File 'lib/codeminer/expressions/expression_container.rb', line 5

def type
  @type
end

#valueObject (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

#eachObject



22
23
24
# File 'lib/codeminer/expressions/expression_container.rb', line 22

def each
  @body
end