Class: RTFDoc::Section
- Inherits:
-
Object
- Object
- RTFDoc::Section
- Includes:
- Anchorable, RenderAsSection
- Defined in:
- lib/rtfdoc.rb
Instance Attribute Summary collapse
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #anchor_id ⇒ Object
- #id ⇒ Object
-
#initialize(name, raw_content, resource: nil) ⇒ Section
constructor
A new instance of Section.
- #menu_output ⇒ Object
- #resource_name ⇒ Object
- #signature ⇒ Object
Methods included from Anchorable
Methods included from RenderAsSection
#content_to_html, #example_to_html, included
Constructor Details
#initialize(name, raw_content, resource: nil) ⇒ Section
Returns a new instance of Section.
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/rtfdoc.rb', line 147 def initialize(name, raw_content, resource: nil) @name = name @resource = resource = nil if raw_content.start_with?('---') idx = raw_content.index('---', 4) raise 'bad format' unless idx (YAML.load(raw_content.slice!(0, idx + 3))) end raise 'missing metadata' if resource && !@path && !@method @content, @example = raw_content.split('$$$') end |
Instance Attribute Details
#method ⇒ Object (readonly)
Returns the value of attribute method.
145 146 147 |
# File 'lib/rtfdoc.rb', line 145 def method @method end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
145 146 147 |
# File 'lib/rtfdoc.rb', line 145 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
145 146 147 |
# File 'lib/rtfdoc.rb', line 145 def path @path end |
Instance Method Details
#anchor_id ⇒ Object
167 168 169 |
# File 'lib/rtfdoc.rb', line 167 def anchor_id @resource ? "#{@resource}-#{id}" : id end |
#id ⇒ Object
163 164 165 |
# File 'lib/rtfdoc.rb', line 163 def id @id ||= name end |
#menu_output ⇒ Object
175 176 177 |
# File 'lib/rtfdoc.rb', line 175 def "<li>#{anchor()}</li>" end |
#resource_name ⇒ Object
171 172 173 |
# File 'lib/rtfdoc.rb', line 171 def resource_name @resource end |
#signature ⇒ Object
179 180 181 182 183 184 185 186 187 188 |
# File 'lib/rtfdoc.rb', line 179 def signature sig = <<-HTML.strip! <div class="endpoint-def"> <div class="method method__#{method.downcase}">#{method.upcase}</div> <div class="path">#{path}</div> </div> HTML anchor(sig) end |