Class: Middleman::Webcomic::Story

Inherits:
Object
  • Object
show all
Defined in:
lib/middleman-webcomic/data.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#comicsObject

Returns the value of attribute comics.



57
58
59
# File 'lib/middleman-webcomic/data.rb', line 57

def comics
  @comics
end

#positionObject

Returns the value of attribute position.



57
58
59
# File 'lib/middleman-webcomic/data.rb', line 57

def position
  @position
end

#slugObject

Returns the value of attribute slug.



57
58
59
# File 'lib/middleman-webcomic/data.rb', line 57

def slug
  @slug
end

#titleObject

Returns the value of attribute title.



57
58
59
# File 'lib/middleman-webcomic/data.rb', line 57

def title
  @title
end

Class Method Details

.allObject



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_dateObject



66
67
68
# File 'lib/middleman-webcomic/data.rb', line 66

def pub_date
  @comics.last.pub_date
end