class Decode::Segment
A chunk of code with an optional preceeding comment block.
~~~ ruby # Get the first segment from a source file: segment = source.segments.first ~~~
Attributes
comments[R]
The preceeding comments. @attribute [Array(String)]
language[R]
The language of the code attached to this segment. @attribute [Language::Generic]
Public Class Methods
new(comments, language)
click to toggle source
# File lib/decode/segment.rb, line 32 def initialize(comments, language) @comments = comments @language = language end
Public Instance Methods
code()
click to toggle source
The source code trailing the comments. @returns [String | nil]
# File lib/decode/segment.rb, line 55 def code end
documentation()
click to toggle source
An interface for accsssing the documentation of the definition. @returns [Documentation | nil] A {Documentation} instance if this definition has comments.
# File lib/decode/segment.rb, line 47 def documentation if @comments&.any? @documentation ||= Documentation.new(@comments, @language) end end