Class: Decode::Segment
- Inherits:
-
Object
- Object
- Decode::Segment
- Defined in:
- lib/decode/segment.rb
Overview
A chunk of code with an optional preceeding comment block.
~~~ ruby # Get the first segment from a source file: segment = source.segments.first ~~~
Direct Known Subclasses
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
The preceeding comments.
-
#language ⇒ Object
readonly
The language of the code attached to this segment.
Instance Method Summary collapse
-
#code ⇒ Object
The source code trailing the comments.
-
#documentation ⇒ Object
An interface for accsssing the documentation of the definition.
-
#initialize(comments, language) ⇒ Segment
constructor
A new instance of Segment.
Constructor Details
#initialize(comments, language) ⇒ Segment
Returns a new instance of Segment.
32 33 34 35 |
# File 'lib/decode/segment.rb', line 32 def initialize(comments, language) @comments = comments @language = language end |
Instance Attribute Details
#comments ⇒ Object (readonly)
The preceeding comments.
39 40 41 |
# File 'lib/decode/segment.rb', line 39 def comments @comments end |
#language ⇒ Object (readonly)
The language of the code attached to this segment.
43 44 45 |
# File 'lib/decode/segment.rb', line 43 def language @language end |
Instance Method Details
#code ⇒ Object
The source code trailing the comments.
55 56 |
# File 'lib/decode/segment.rb', line 55 def code end |
#documentation ⇒ Object
An interface for accsssing the documentation of the definition.
47 48 49 50 51 |
# File 'lib/decode/segment.rb', line 47 def documentation if @comments&.any? @documentation ||= Documentation.new(@comments, @language) end end |