Class: NHKore::SearchLink
- Inherits:
-
Object
- Object
- NHKore::SearchLink
- Extended by:
- AttrBool::Ext
- Defined in:
- lib/nhkore/search_link.rb
Instance Attribute Summary collapse
-
#datetime ⇒ Object
Returns the value of attribute datetime.
-
#futsuurl ⇒ Object
Returns the value of attribute futsuurl.
-
#sha256 ⇒ Object
Returns the value of attribute sha256.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #encode_with(coder) ⇒ Object
-
#initialize(url, scraped: false) ⇒ SearchLink
constructor
A new instance of SearchLink.
- #to_s(mini: false) ⇒ Object
- #update_from_article(article) ⇒ Object
Constructor Details
#initialize(url, scraped: false) ⇒ SearchLink
Returns a new instance of SearchLink.
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/nhkore/search_link.rb', line 30 def initialize(url,scraped: false) super() @datetime = nil @futsuurl = nil @scraped = scraped @sha256 = sha256 @title = nil self.url = url end |
Instance Attribute Details
#datetime ⇒ Object
Returns the value of attribute datetime.
23 24 25 |
# File 'lib/nhkore/search_link.rb', line 23 def datetime @datetime end |
#futsuurl ⇒ Object
Returns the value of attribute futsuurl.
24 25 26 |
# File 'lib/nhkore/search_link.rb', line 24 def futsuurl @futsuurl end |
#sha256 ⇒ Object
Returns the value of attribute sha256.
26 27 28 |
# File 'lib/nhkore/search_link.rb', line 26 def sha256 @sha256 end |
#title ⇒ Object
Returns the value of attribute title.
27 28 29 |
# File 'lib/nhkore/search_link.rb', line 27 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
28 29 30 |
# File 'lib/nhkore/search_link.rb', line 28 def url @url end |
Class Method Details
.load_data(key, hash) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/nhkore/search_link.rb', line 52 def self.load_data(key,hash) slink = SearchLink.new( hash[:url], scraped: hash[:scraped], ) slink.datetime = hash[:datetime] slink.futsuurl = hash[:futsuurl] slink.sha256 = hash[:sha256] slink.title = hash[:title] return slink end |
Instance Method Details
#encode_with(coder) ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/nhkore/search_link.rb', line 41 def encode_with(coder) # Order matters. coder[:url] = @url&.to_s coder[:scraped] = @scraped coder[:datetime] = @datetime&.iso8601 coder[:title] = @title coder[:futsuurl] = @futsuurl&.to_s coder[:sha256] = @sha256 end |
#to_s(mini: false) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/nhkore/search_link.rb', line 94 def to_s(mini: false) s = ''.dup s << "'#{@url}': " if mini s << "{ scraped? #{@scraped ? 'yes' : 'NO'} }" else s << "\n scraped? #{@scraped ? 'yes' : 'NO'}" s << "\n datetime: '#{@datetime}'" s << "\n title: '#{@title}'" s << "\n futsuurl: '#{@futsuurl}'" s << "\n sha256: '#{@sha256}'" end return s end |
#update_from_article(article) ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/nhkore/search_link.rb', line 66 def update_from_article(article) # Don't update the url, as it may be different (e.g., http vs https). self.datetime = article.datetime if @datetime.nil? self.futsuurl = article.futsuurl if Util.empty_web_str?(@futsuurl) @scraped = true # If we have an article, it's been scraped @sha256 = article.sha256 if Util.empty_web_str?(@sha256) @title = article.title if Util.empty_web_str?(@title) end |