Class: Rubaiji::Result
- Inherits:
-
Object
- Object
- Rubaiji::Result
- Defined in:
- lib/rubaiji/result.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#images ⇒ Object
readonly
Returns the value of attribute images.
-
#keywords ⇒ Object
readonly
Returns the value of attribute keywords.
-
#link ⇒ Object
readonly
Returns the value of attribute link.
-
#old_rank ⇒ Object
readonly
Returns the value of attribute old_rank.
-
#rank ⇒ Object
readonly
Returns the value of attribute rank.
-
#smart ⇒ Object
readonly
Returns the value of attribute smart.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#summary ⇒ Object
readonly
Returns the value of attribute summary.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#videos ⇒ Object
Returns the value of attribute videos.
Instance Method Summary collapse
- #has_videos? ⇒ Boolean
-
#initialize(params) ⇒ Result
constructor
A new instance of Result.
- #new? ⇒ Boolean
- #old? ⇒ Boolean
- #smart? ⇒ Boolean
Constructor Details
#initialize(params) ⇒ Result
Returns a new instance of Result.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rubaiji/result.rb', line 7 def initialize(params) params.each do |k, v| instance_variable_set("@#{k}", v) unless v.nil? or k == "videos" end self.videos = [] params["videos"] = params["videos"].gsub('\'', '"') _res = JSON.parse("\{\"videos\": #{params["videos"]}\}") if _res["videos"].class == String _res["videos"] = JSON.parse(_res["videos"]) end _res["videos"].each do |video| self.videos << Rubaiji::Video.new(video) end #rescue #end end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/rubaiji/result.rb', line 3 def id @id end |
#images ⇒ Object (readonly)
Returns the value of attribute images.
3 4 5 |
# File 'lib/rubaiji/result.rb', line 3 def images @images end |
#keywords ⇒ Object (readonly)
Returns the value of attribute keywords.
3 4 5 |
# File 'lib/rubaiji/result.rb', line 3 def keywords @keywords end |
#link ⇒ Object (readonly)
Returns the value of attribute link.
3 4 5 |
# File 'lib/rubaiji/result.rb', line 3 def link @link end |
#old_rank ⇒ Object (readonly)
Returns the value of attribute old_rank.
3 4 5 |
# File 'lib/rubaiji/result.rb', line 3 def old_rank @old_rank end |
#rank ⇒ Object (readonly)
Returns the value of attribute rank.
3 4 5 |
# File 'lib/rubaiji/result.rb', line 3 def rank @rank end |
#smart ⇒ Object (readonly)
Returns the value of attribute smart.
3 4 5 |
# File 'lib/rubaiji/result.rb', line 3 def smart @smart end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
3 4 5 |
# File 'lib/rubaiji/result.rb', line 3 def status @status end |
#summary ⇒ Object (readonly)
Returns the value of attribute summary.
3 4 5 |
# File 'lib/rubaiji/result.rb', line 3 def summary @summary end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
3 4 5 |
# File 'lib/rubaiji/result.rb', line 3 def title @title end |
#videos ⇒ Object
Returns the value of attribute videos.
5 6 7 |
# File 'lib/rubaiji/result.rb', line 5 def videos @videos end |
Instance Method Details
#has_videos? ⇒ Boolean
39 40 41 |
# File 'lib/rubaiji/result.rb', line 39 def has_videos? videos.size > 0 end |
#new? ⇒ Boolean
31 32 33 |
# File 'lib/rubaiji/result.rb', line 31 def new? status == "1" end |
#old? ⇒ Boolean
27 28 29 |
# File 'lib/rubaiji/result.rb', line 27 def old? status == "0" end |
#smart? ⇒ Boolean
35 36 37 |
# File 'lib/rubaiji/result.rb', line 35 def smart? smart == true end |