Class: AllCollectionsHooks::APage
- Inherits:
-
Object
- Object
- AllCollectionsHooks::APage
- Defined in:
- lib/all_collections_hooks.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#destination ⇒ Object
readonly
Returns the value of attribute destination.
-
#draft ⇒ Object
readonly
Returns the value of attribute draft.
-
#excerpt ⇒ Object
readonly
Returns the value of attribute excerpt.
-
#ext ⇒ Object
readonly
Returns the value of attribute ext.
-
#extname ⇒ Object
readonly
Returns the value of attribute extname.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#last_modified ⇒ Object
readonly
Returns the value of attribute last_modified.
-
#layout ⇒ Object
readonly
Returns the value of attribute layout.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#relative_path ⇒ Object
readonly
Returns the value of attribute relative_path.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(obj) ⇒ APage
constructor
Verify each property exists before accessing it; this helps write tests.
- #to_s ⇒ Object
Constructor Details
#initialize(obj) ⇒ APage
Verify each property exists before accessing it; this helps write tests
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/all_collections_hooks.rb', line 73 def initialize(obj) @data = obj.data if obj.respond_to? :data @categories = @data['categories'] if @data.key? 'categories' @content = obj.content if obj.respond_to? :content @date = (@data['date'].to_date if @data&.key?('date')) || Date.today @description = @data['description'] if @data.key? 'description' # TODO: What _config.yml setting should be passed to destination()? @destination = obj.destination('') if obj.respond_to? :destination @draft = Jekyll::Draft.draft?(obj) @excerpt = @data['excerpt'] if @data.key? 'excerpt' @ext = obj.extname @ext ||= @data['ext'] if @data.key? 'ext' @extname = @ext # For compatibility with previous versions of all_collections @label = obj.collection.label if obj&.collection.respond_to? :label @last_modified = @data['last_modified'] || @data['last_modified_at'] || @date @last_modified_field = case @data when @data.key?('last_modified') 'last_modified' when @data.key?('last_modified_at') 'last_modified_at' end @layout = @data['layout'] if @data.key? 'layout' @path = obj.path if obj.respond_to? :path @relative_path = obj.relative_path if obj.respond_to? :relative_path @tags = @data['tags'] if @data.key? 'tags' @title = @data['title'] if @data.key? 'title' @type = obj.type if obj.respond_to? :type @url = obj.url end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
69 70 71 |
# File 'lib/all_collections_hooks.rb', line 69 def content @content end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
69 70 71 |
# File 'lib/all_collections_hooks.rb', line 69 def data @data end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
69 70 71 |
# File 'lib/all_collections_hooks.rb', line 69 def date @date end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
69 70 71 |
# File 'lib/all_collections_hooks.rb', line 69 def description @description end |
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
69 70 71 |
# File 'lib/all_collections_hooks.rb', line 69 def destination @destination end |
#draft ⇒ Object (readonly)
Returns the value of attribute draft.
69 70 71 |
# File 'lib/all_collections_hooks.rb', line 69 def draft @draft end |
#excerpt ⇒ Object (readonly)
Returns the value of attribute excerpt.
69 70 71 |
# File 'lib/all_collections_hooks.rb', line 69 def excerpt @excerpt end |
#ext ⇒ Object (readonly)
Returns the value of attribute ext.
69 70 71 |
# File 'lib/all_collections_hooks.rb', line 69 def ext @ext end |
#extname ⇒ Object (readonly)
Returns the value of attribute extname.
69 70 71 |
# File 'lib/all_collections_hooks.rb', line 69 def extname @extname end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
69 70 71 |
# File 'lib/all_collections_hooks.rb', line 69 def label @label end |
#last_modified ⇒ Object (readonly)
Returns the value of attribute last_modified.
69 70 71 |
# File 'lib/all_collections_hooks.rb', line 69 def last_modified @last_modified end |
#layout ⇒ Object (readonly)
Returns the value of attribute layout.
69 70 71 |
# File 'lib/all_collections_hooks.rb', line 69 def layout @layout end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
69 70 71 |
# File 'lib/all_collections_hooks.rb', line 69 def path @path end |
#relative_path ⇒ Object (readonly)
Returns the value of attribute relative_path.
69 70 71 |
# File 'lib/all_collections_hooks.rb', line 69 def relative_path @relative_path end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
69 70 71 |
# File 'lib/all_collections_hooks.rb', line 69 def @tags end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
69 70 71 |
# File 'lib/all_collections_hooks.rb', line 69 def title @title end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
69 70 71 |
# File 'lib/all_collections_hooks.rb', line 69 def type @type end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
69 70 71 |
# File 'lib/all_collections_hooks.rb', line 69 def url @url end |
Instance Method Details
#to_s ⇒ Object
106 107 108 109 110 |
# File 'lib/all_collections_hooks.rb', line 106 def to_s return @label if @label @date.to_s end |