Class: LowVoltage::Post

Inherits:
Object
  • Object
show all
Defined in:
lib/low_voltage/post.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Post

Returns a new instance of Post.



7
8
9
10
11
12
13
14
15
16
# File 'lib/low_voltage/post.rb', line 7

def initialize(path)
  @id = File.basename(path, ".md")
  @path = path

  begin
    parse_post(Metadown.render(IO.read(@path)))
  rescue Errno::ENOENT
    raise ActionController::RoutingError, "Post not found: #{path}"
  end
end

Instance Attribute Details

#authorObject (readonly)

Returns the value of attribute author.



5
6
7
# File 'lib/low_voltage/post.rb', line 5

def author
  @author
end

#contentObject (readonly)

Returns the value of attribute content.



5
6
7
# File 'lib/low_voltage/post.rb', line 5

def content
  @content
end

#dateObject (readonly)

Returns the value of attribute date.



5
6
7
# File 'lib/low_voltage/post.rb', line 5

def date
  @date
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/low_voltage/post.rb', line 5

def id
  @id
end

#titleObject (readonly)

Returns the value of attribute title.



5
6
7
# File 'lib/low_voltage/post.rb', line 5

def title
  @title
end