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
Returns the value of attribute comments.
-
#language ⇒ Object
readonly
Returns the value of attribute language.
- #The language of the code attached to this segment.(languageofthecodeattachedtothissegment.) ⇒ Object readonly
- #The preceeding comments.(preceedingcomments.) ⇒ Object readonly
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
Initialize a new segment.
Constructor Details
#initialize(comments, language) ⇒ Segment
Initialize a new segment.
20 21 22 23 24 |
# File 'lib/decode/segment.rb', line 20 def initialize(comments, language) @comments = comments @language = language @documentation = nil end |
Instance Attribute Details
#comments ⇒ Object (readonly)
Returns the value of attribute comments.
27 28 29 |
# File 'lib/decode/segment.rb', line 27 def comments @comments end |
#language ⇒ Object (readonly)
Returns the value of attribute language.
30 31 32 |
# File 'lib/decode/segment.rb', line 30 def language @language end |
#The language of the code attached to this segment.(languageofthecodeattachedtothissegment.) ⇒ Object (readonly)
30 |
# File 'lib/decode/segment.rb', line 30 attr :language |
#The preceeding comments.(preceedingcomments.) ⇒ Object (readonly)
27 |
# File 'lib/decode/segment.rb', line 27 attr :comments |
Instance Method Details
#code ⇒ Object
The source code trailing the comments.
42 43 |
# File 'lib/decode/segment.rb', line 42 def code end |
#documentation ⇒ Object
An interface for accsssing the documentation of the definition.
34 35 36 37 38 |
# File 'lib/decode/segment.rb', line 34 def documentation if @comments&.any? @documentation ||= Documentation.new(@comments, @language) end end |