Class: NewsApi::Article

Inherits:
Struct
  • Object
show all
Defined in:
lib/chid/news_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#authorObject

Returns the value of attribute author

Returns:

  • (Object)

    the current value of author



6
7
8
# File 'lib/chid/news_api.rb', line 6

def author
  @author
end

#descriptionObject

Returns the value of attribute description

Returns:

  • (Object)

    the current value of description



6
7
8
# File 'lib/chid/news_api.rb', line 6

def description
  @description
end

#publishedAtObject

Returns the value of attribute publishedAt

Returns:

  • (Object)

    the current value of publishedAt



6
7
8
# File 'lib/chid/news_api.rb', line 6

def publishedAt
  @publishedAt
end

#sourceObject

Returns the value of attribute source

Returns:

  • (Object)

    the current value of source



6
7
8
# File 'lib/chid/news_api.rb', line 6

def source
  @source
end

#titleObject

Returns the value of attribute title

Returns:

  • (Object)

    the current value of title



6
7
8
# File 'lib/chid/news_api.rb', line 6

def title
  @title
end

#urlObject

Returns the value of attribute url

Returns:

  • (Object)

    the current value of url



6
7
8
# File 'lib/chid/news_api.rb', line 6

def url
  @url
end

Instance Method Details

#summaryObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/chid/news_api.rb', line 7

def summary
  published_at = publishedAt.nil? ? 'unkown' : publishedAt.strftime("%B %d, %Y")
  print "\n"
  print "--- #{title} ---".blue
  print "\n"
  print "  Posted #{published_at} by ".brown
  print "#{author}".green
  print "\n\n"
  print "  #{description}"
  print "\n\n"
  print "  Link: "
  print "#{url}".cyan.underline
  print "\n"
end