Class: Benoit::Page
- Inherits:
-
Object
- Object
- Benoit::Page
- Defined in:
- lib/benoit/page.rb
Instance Attribute Summary collapse
-
#attrs_hash ⇒ Object
readonly
Returns the value of attribute attrs_hash.
-
#permalink ⇒ Object
readonly
Returns the value of attribute permalink.
-
#siteContext ⇒ Object
readonly
Returns the value of attribute siteContext.
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #has_value?(value) ⇒ Boolean
-
#initialize(attrs) ⇒ Page
constructor
A new instance of Page.
- #key?(key) ⇒ Boolean
- #keys ⇒ Object
- #set_permalink!(attrs) ⇒ Object
- #template ⇒ Object
- #to_hash(options = {}) ⇒ Object
- #to_json(options = {}) ⇒ Object
Constructor Details
#initialize(attrs) ⇒ Page
Returns a new instance of Page.
9 10 11 12 13 14 15 |
# File 'lib/benoit/page.rb', line 9 def initialize(attrs) @attr_names = @attrNames = [] @original_path = attrs["_original_path"] setFileType!(attrs) set_permalink!(attrs) @metadata = methodsFromAttrs(attrs) end |
Instance Attribute Details
#attrs_hash ⇒ Object (readonly)
Returns the value of attribute attrs_hash.
3 4 5 |
# File 'lib/benoit/page.rb', line 3 def attrs_hash @attrs_hash end |
#permalink ⇒ Object (readonly)
Returns the value of attribute permalink.
3 4 5 |
# File 'lib/benoit/page.rb', line 3 def permalink @permalink end |
#siteContext ⇒ Object (readonly)
Returns the value of attribute siteContext.
3 4 5 |
# File 'lib/benoit/page.rb', line 3 def siteContext @siteContext end |
Class Method Details
.from_hash(page_attrs) ⇒ Object
5 6 7 |
# File 'lib/benoit/page.rb', line 5 def self.from_hash(page_attrs) new(page_attrs) end |
Instance Method Details
#[](key) ⇒ Object
30 31 32 |
# File 'lib/benoit/page.rb', line 30 def [](key) @metadata[key] end |
#[]=(key, value) ⇒ Object
34 35 36 37 |
# File 'lib/benoit/page.rb', line 34 def []=(key, value) instance_variable_set("@#{key}", value) @metadata[key] = value end |
#has_value?(value) ⇒ Boolean
22 23 24 |
# File 'lib/benoit/page.rb', line 22 def has_value?(value) @metadata.has_value?(value) end |
#key?(key) ⇒ Boolean
26 27 28 |
# File 'lib/benoit/page.rb', line 26 def key?(key) @metadata.key?(key) end |
#keys ⇒ Object
39 40 41 |
# File 'lib/benoit/page.rb', line 39 def keys @metadata.keys end |
#set_permalink!(attrs) ⇒ Object
43 44 45 46 |
# File 'lib/benoit/page.rb', line 43 def set_permalink!(attrs) @permalink = "/#{@original_path}" @attrNames << :permalink end |
#template ⇒ Object
17 18 19 20 |
# File 'lib/benoit/page.rb', line 17 def template # For compat with other site generators @template || @layout end |
#to_hash(options = {}) ⇒ Object
52 53 54 |
# File 'lib/benoit/page.rb', line 52 def to_hash(={}) attrsFromMethods(@attrNames) end |
#to_json(options = {}) ⇒ Object
48 49 50 |
# File 'lib/benoit/page.rb', line 48 def to_json(={}) attrsFromMethods(@attrNames).to_json end |