Class: CodeMiner::BodyExpression
- Inherits:
-
Expression
- Object
- Expression
- CodeMiner::BodyExpression
- Defined in:
- lib/codeminer/expressions/body_expression.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#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(statement) ⇒ Object
- #each ⇒ Object
-
#initialize(src, body = []) ⇒ BodyExpression
constructor
A new instance of BodyExpression.
- #type ⇒ Object
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(src, body = []) ⇒ BodyExpression
Returns a new instance of BodyExpression.
12 13 14 15 |
# File 'lib/codeminer/expressions/body_expression.rb', line 12 def initialize(src, body=[]) @src_fallback = src @body = body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
10 11 12 |
# File 'lib/codeminer/expressions/body_expression.rb', line 10 def body @body end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
10 11 12 |
# File 'lib/codeminer/expressions/body_expression.rb', line 10 def value @value end |
Class Method Details
.from(*expressions) ⇒ Object
5 6 7 8 |
# File 'lib/codeminer/expressions/body_expression.rb', line 5 def self.from(*expressions) adjusted_src = expressions.first.src_extract.adjust(expressions.last.src_extract) new(adjusted_src, expressions) end |
Instance Method Details
#add(statement) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/codeminer/expressions/body_expression.rb', line 17 def add(statement) unless statement.kind_of?(VoidExpression) adjust_src(statement.src_extract) @body << statement end self end |
#each ⇒ Object
25 26 27 |
# File 'lib/codeminer/expressions/body_expression.rb', line 25 def each @body.each.to_a end |
#type ⇒ Object
29 30 31 |
# File 'lib/codeminer/expressions/body_expression.rb', line 29 def type :body end |