Class: Middleman::Webcomic::Story
- Inherits:
-
Object
- Object
- Middleman::Webcomic::Story
- Defined in:
- lib/middleman-webcomic/data.rb
Instance Attribute Summary collapse
-
#comics ⇒ Object
Returns the value of attribute comics.
-
#position ⇒ Object
Returns the value of attribute position.
-
#slug ⇒ Object
Returns the value of attribute slug.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
- #add_comic(comic) ⇒ Object
-
#initialize(title) ⇒ Story
constructor
A new instance of Story.
- #pub_date ⇒ Object
Constructor Details
#initialize(title) ⇒ Story
Returns a new instance of Story.
59 60 61 62 63 64 |
# File 'lib/middleman-webcomic/data.rb', line 59 def initialize(title) @title= title @slug= @title.create_slug @comics= [] @position= nil end |
Instance Attribute Details
#comics ⇒ Object
Returns the value of attribute comics.
57 58 59 |
# File 'lib/middleman-webcomic/data.rb', line 57 def comics @comics end |
#position ⇒ Object
Returns the value of attribute position.
57 58 59 |
# File 'lib/middleman-webcomic/data.rb', line 57 def position @position end |
#slug ⇒ Object
Returns the value of attribute slug.
57 58 59 |
# File 'lib/middleman-webcomic/data.rb', line 57 def slug @slug end |
#title ⇒ Object
Returns the value of attribute title.
57 58 59 |
# File 'lib/middleman-webcomic/data.rb', line 57 def title @title end |
Class Method Details
.all ⇒ Object
76 77 78 79 |
# File 'lib/middleman-webcomic/data.rb', line 76 def all @stories ||= {} @stories.values end |
.find_or_create_for(comic) ⇒ Object
81 82 83 84 85 86 87 88 89 |
# File 'lib/middleman-webcomic/data.rb', line 81 def find_or_create_for(comic) title= comic.story @stories ||= {} unless @stories.has_key? title story= @stories[title]= new(title) end @stories[title].add_comic comic @stories[title] end |
Instance Method Details
#add_comic(comic) ⇒ Object
70 71 72 |
# File 'lib/middleman-webcomic/data.rb', line 70 def add_comic(comic) @comics << comic end |
#pub_date ⇒ Object
66 67 68 |
# File 'lib/middleman-webcomic/data.rb', line 66 def pub_date @comics.last.pub_date end |