Class: ApiGuides::Reference
- Inherits:
-
Object
- Object
- ApiGuides::Reference
- Defined in:
- lib/api_guides/reference.rb
Overview
This class models a
References can also be linked to using standard markdown syntax with some sugar provided by this library.
Each reference has a title. The title is used for linking and descirbing each reference. You should markdown inside each reference to fill in your content
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
-
.from_xml(xml) ⇒ Object
Takes an XML representation and parse it into a Reference instance.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Reference
constructor
A new instance of Reference.
Constructor Details
#initialize(attributes = {}) ⇒ Reference
Returns a new instance of Reference.
18 19 20 21 22 |
# File 'lib/api_guides/reference.rb', line 18 def initialize(attributes = {}) attributes.each_pair do |attr, value| send "#{attr}=", value end end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
16 17 18 |
# File 'lib/api_guides/reference.rb', line 16 def content @content end |
#title ⇒ Object
Returns the value of attribute title.
16 17 18 |
# File 'lib/api_guides/reference.rb', line 16 def title @title end |
Class Method Details
.from_xml(xml) ⇒ Object
Takes an XML representation and parse it into a Reference instance.
Here is XML format expected:
<reference title="Foo">
<![CDATA[
Insert your markdown here
]]>
</reference>
This would set #title to 'Foo'
and #content to 'Insert your markdown here'
37 38 39 40 |
# File 'lib/api_guides/reference.rb', line 37 def self.from_xml(xml) doc = Nokogiri::XML.parse(xml).at_xpath('//reference') Reference.new :title => doc.attributes['title'].try(:value), :content => doc.content end |