Class: NPR::Story

Inherits:
Content show all
Defined in:
lib/rubynpr/story.rb

Overview

Story represents an NPR story. ruby-npr gives you the following attributes to work with on a Story object:

  • id - unique NPR identifier for each story

  • title - the title of the story.

  • subtitle - a short description of the story

  • bylines - a listing of the story’s author(s)

  • teaser - summary of the story

  • mini_teaser - an even shorter summary of the story

  • slug - the main association for the returned story, be it a topic, series, column or other list from NPR

  • organization - the owner of the story

  • story_date - the date the story was published

  • publication_date - the date the story was initially published to NPR. Also can be accessed by pub_date

  • last_modified - the date the story was last modified in any sort of way

  • audio - a story’s audio attachment

  • show - which show this story originated from (if there was one)

  • parents - parent topics for this story, i.e. economy, health & science, etc.

  • products - any associated products that are included with the story. Usually books.

  • related_links - links to NPR content related to the given story

  • html_text - returns an array of the paragraphs of the text of the story. Includes all the HTML links and such as originally included in the body of the story.

  • plain_text - also returns an array of the paragraphs of the text of the story. Does not include any HTML.

  • images - any images associated with a story

  • link - a hash with links to the story. Use @some_story.link[:html] to access the web page for the given Story. Use @some_story.link[:api] to access the API representation of the given Story.

Instance Attribute Summary collapse

Method Summary

Methods inherited from Content

#initialize

Constructor Details

This class inherits a constructor from NPR::Content

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object (private)



84
85
86
87
88
89
# File 'lib/rubynpr/story.rb', line 84

def method_missing(method_name, *args)
  return nil unless method_name.to_s =~ /process_story_(bylines|parents|products|images)/
  klass = method_name.to_s.split('_').last 
  instance_variable_set("@#{ klass }", []) if instance_variable_get("@#{ klass }").nil?
  instance_variable_get("@#{ klass }") << NPR.const_get(klass.capitalize.chop).new(args[0])
end

Instance Attribute Details

#audioObject

Returns the value of attribute audio.



30
31
32
# File 'lib/rubynpr/story.rb', line 30

def audio
  @audio
end

#bylinesObject

Returns the value of attribute bylines.



30
31
32
# File 'lib/rubynpr/story.rb', line 30

def 
  @bylines
end

#html_textObject

Returns the value of attribute html_text.



30
31
32
# File 'lib/rubynpr/story.rb', line 30

def html_text
  @html_text
end

#idObject

Returns the value of attribute id.



30
31
32
# File 'lib/rubynpr/story.rb', line 30

def id
  @id
end

#imagesObject

Returns the value of attribute images.



30
31
32
# File 'lib/rubynpr/story.rb', line 30

def images
  @images
end

#keywordsObject

Returns the value of attribute keywords.



30
31
32
# File 'lib/rubynpr/story.rb', line 30

def keywords
  @keywords
end

#last_modifiedObject

Returns the value of attribute last_modified.



30
31
32
# File 'lib/rubynpr/story.rb', line 30

def last_modified
  @last_modified
end

Returns the value of attribute link.



30
31
32
# File 'lib/rubynpr/story.rb', line 30

def link
  @link
end

Returns the value of attribute links.



30
31
32
# File 'lib/rubynpr/story.rb', line 30

def links
  @links
end

#mini_teaserObject

Returns the value of attribute mini_teaser.



30
31
32
# File 'lib/rubynpr/story.rb', line 30

def mini_teaser
  @mini_teaser
end

#organizationObject Also known as: org

Returns the value of attribute organization.



30
31
32
# File 'lib/rubynpr/story.rb', line 30

def organization
  @organization
end

#parentsObject

Returns the value of attribute parents.



30
31
32
# File 'lib/rubynpr/story.rb', line 30

def parents
  @parents
end

#plain_textObject

Returns the value of attribute plain_text.



30
31
32
# File 'lib/rubynpr/story.rb', line 30

def plain_text
  @plain_text
end

#priority_keywordsObject

Returns the value of attribute priority_keywords.



30
31
32
# File 'lib/rubynpr/story.rb', line 30

def priority_keywords
  @priority_keywords
end

#productsObject

Returns the value of attribute products.



30
31
32
# File 'lib/rubynpr/story.rb', line 30

def products
  @products
end

#publication_dateObject Also known as: pub_date

Returns the value of attribute publication_date.



30
31
32
# File 'lib/rubynpr/story.rb', line 30

def publication_date
  @publication_date
end

Returns the value of attribute related_links.



30
31
32
# File 'lib/rubynpr/story.rb', line 30

def related_links
  @related_links
end

#short_titleObject

Returns the value of attribute short_title.



30
31
32
# File 'lib/rubynpr/story.rb', line 30

def short_title
  @short_title
end

#showObject

Returns the value of attribute show.



30
31
32
# File 'lib/rubynpr/story.rb', line 30

def show
  @show
end

#slugObject

Returns the value of attribute slug.



30
31
32
# File 'lib/rubynpr/story.rb', line 30

def slug
  @slug
end

#story_dateObject

Returns the value of attribute story_date.



30
31
32
# File 'lib/rubynpr/story.rb', line 30

def 
  @story_date
end

#subtitleObject

Returns the value of attribute subtitle.



30
31
32
# File 'lib/rubynpr/story.rb', line 30

def subtitle
  @subtitle
end

#teaserObject

Returns the value of attribute teaser.



30
31
32
# File 'lib/rubynpr/story.rb', line 30

def teaser
  @teaser
end

#titleObject

Returns the value of attribute title.



30
31
32
# File 'lib/rubynpr/story.rb', line 30

def title
  @title
end