Class: RLSL::Prism::SourceUnit
- Inherits:
-
Struct
- Object
- Struct
- RLSL::Prism::SourceUnit
- Defined in:
- lib/rlsl/prism/source_unit.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#params ⇒ Object
Returns the value of attribute params.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body
7 8 9 |
# File 'lib/rlsl/prism/source_unit.rb', line 7 def body @body end |
#params ⇒ Object
Returns the value of attribute params
7 8 9 |
# File 'lib/rlsl/prism/source_unit.rb', line 7 def params @params end |
Class Method Details
.from_block(block) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/rlsl/prism/source_unit.rb', line 13 def from_block(block) new( params: extract_params(block), body: block.body&.slice.to_s.strip ) end |
.from_source(source) ⇒ Object
9 10 11 |
# File 'lib/rlsl/prism/source_unit.rb', line 9 def from_source(source) SourceUnitParser.new(source).parse end |
Instance Method Details
#to_source ⇒ Object
34 35 36 37 38 39 |
# File 'lib/rlsl/prism/source_unit.rb', line 34 def to_source segments = [] segments << "|#{params.join(', ')}|" unless params.empty? segments << body unless body.empty? segments.join("\n") end |
#without_params ⇒ Object
30 31 32 |
# File 'lib/rlsl/prism/source_unit.rb', line 30 def without_params self.class.new(params: [], body: body) end |