Class: Rubaiji::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/rubaiji/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/rubaiji/result.rb', line 3

def id
  @id
end

#imagesObject (readonly)

Returns the value of attribute images.



3
4
5
# File 'lib/rubaiji/result.rb', line 3

def images
  @images
end

#keywordsObject (readonly)

Returns the value of attribute keywords.



3
4
5
# File 'lib/rubaiji/result.rb', line 3

def keywords
  @keywords
end

Returns the value of attribute link.



3
4
5
# File 'lib/rubaiji/result.rb', line 3

def link
  @link
end

#old_rankObject (readonly)

Returns the value of attribute old_rank.



3
4
5
# File 'lib/rubaiji/result.rb', line 3

def old_rank
  @old_rank
end

#rankObject (readonly)

Returns the value of attribute rank.



3
4
5
# File 'lib/rubaiji/result.rb', line 3

def rank
  @rank
end

#smartObject (readonly)

Returns the value of attribute smart.



3
4
5
# File 'lib/rubaiji/result.rb', line 3

def smart
  @smart
end

#statusObject (readonly)

Returns the value of attribute status.



3
4
5
# File 'lib/rubaiji/result.rb', line 3

def status
  @status
end

#summaryObject (readonly)

Returns the value of attribute summary.



3
4
5
# File 'lib/rubaiji/result.rb', line 3

def summary
  @summary
end

#titleObject (readonly)

Returns the value of attribute title.



3
4
5
# File 'lib/rubaiji/result.rb', line 3

def title
  @title
end

#videosObject

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

Returns:

  • (Boolean)


39
40
41
# File 'lib/rubaiji/result.rb', line 39

def has_videos?
  videos.size > 0
end

#new?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/rubaiji/result.rb', line 31

def new?
  status == "1"
end

#old?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/rubaiji/result.rb', line 27

def old?
  status == "0"
end

#smart?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/rubaiji/result.rb', line 35

def smart?
  smart == true
end