Class: Writefully::Content

Inherits:
Object
  • Object
show all
Defined in:
lib/writefully/content.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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.options[:content], index[:site], index[:resource], index[:slug])
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



4
5
6
# File 'lib/writefully/content.rb', line 4

def body
  @body
end

#indexObject (readonly)

Returns the value of attribute index.



3
4
5
# File 'lib/writefully/content.rb', line 3

def index
  @index
end

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/writefully/content.rb', line 3

def path
  @path
end

Instance Method Details

#detailsObject



19
20
21
# File 'lib/writefully/content.rb', line 19

def details
  Hashie::Mash.new(meta["details"])
end

#metaObject



15
16
17
# File 'lib/writefully/content.rb', line 15

def meta
  YAML.load(File.read(File.join(path, "meta.yml"))).merge({ "position" => position })
end

#positionObject



27
28
29
# File 'lib/writefully/content.rb', line 27

def position
  index[:slug].match(/\A\d*/).to_s.to_i
end

#slugObject



23
24
25
# File 'lib/writefully/content.rb', line 23

def slug
  index[:slug].split(/\A\d*-/).last
end