Class: Writefully::Content
- Inherits:
-
Object
- Object
- Writefully::Content
- Defined in:
- lib/writefully/content.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #details ⇒ Object
-
#initialize(index) ⇒ Content
constructor
A new instance of Content.
- #meta ⇒ Object
- #position ⇒ Object
- #slug ⇒ Object
Constructor Details
#initialize(index) ⇒ Content
Returns a new instance of Content.
6 7 8 9 |
# File 'lib/writefully/content.rb', line 6 def initialize(index) @index = index @path = File.join(Writefully.[:content], index[:site], index[:resource], index[:slug]) end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
4 5 6 |
# File 'lib/writefully/content.rb', line 4 def body @body end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
3 4 5 |
# File 'lib/writefully/content.rb', line 3 def index @index end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/writefully/content.rb', line 3 def path @path end |
Instance Method Details
#details ⇒ Object
19 20 21 |
# File 'lib/writefully/content.rb', line 19 def details Hashie::Mash.new(["details"]) end |
#meta ⇒ Object
15 16 17 |
# File 'lib/writefully/content.rb', line 15 def YAML.load(File.read(File.join(path, "meta.yml"))).merge({ "position" => position }) end |
#position ⇒ Object
27 28 29 |
# File 'lib/writefully/content.rb', line 27 def position index[:slug].match(/\A\d*/).to_s.to_i end |
#slug ⇒ Object
23 24 25 |
# File 'lib/writefully/content.rb', line 23 def slug index[:slug].split(/\A\d*-/).last end |