Class: RTFDoc::Section
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Anchorable
#anchor
#content_to_html, included
Constructor Details
#initialize(name, raw_content, resource: nil) ⇒ Section
Returns a new instance of Section.
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
|
# File 'lib/rtfdoc.rb', line 212
def initialize(name, raw_content, resource: nil)
@name = name
@resource = resource
metadata = nil
if raw_content.start_with?('---')
idx = raw_content.index('---', 4)
raise 'bad format' unless idx
parse_metadata(YAML.load(raw_content.slice!(0, idx + 3)))
end
raise 'missing metadata' if resource && !meta_section? && !@path && !@method
@content, @example = raw_content.split('$$$')
end
|
Instance Attribute Details
#method ⇒ Object
Returns the value of attribute method.
210
211
212
|
# File 'lib/rtfdoc.rb', line 210
def method
@method
end
|
#name ⇒ Object
Returns the value of attribute name.
210
211
212
|
# File 'lib/rtfdoc.rb', line 210
def name
@name
end
|
#path ⇒ Object
Returns the value of attribute path.
210
211
212
|
# File 'lib/rtfdoc.rb', line 210
def path
@path
end
|
Instance Method Details
#anchor_id ⇒ Object
232
233
234
|
# File 'lib/rtfdoc.rb', line 232
def anchor_id
@resource ? "#{@resource}-#{id}" : id
end
|
#example_to_html ⇒ Object
248
249
250
251
|
# File 'lib/rtfdoc.rb', line 248
def example_to_html
res = super
@resource && res && !meta_section? ? res.sub('RESPONSE', sig) : res
end
|
#id ⇒ Object
228
229
230
|
# File 'lib/rtfdoc.rb', line 228
def id
@id ||= name
end
|
240
241
242
|
# File 'lib/rtfdoc.rb', line 240
def
"<li>#{anchor()}</li>"
end
|
#resource_name ⇒ Object
236
237
238
|
# File 'lib/rtfdoc.rb', line 236
def resource_name
@resource
end
|
#signature ⇒ Object
244
245
246
|
# File 'lib/rtfdoc.rb', line 244
def signature
anchor(sig)
end
|