Class: Subscene::SubtitleResult
- Inherits:
-
Object
- Object
- Subscene::SubtitleResult
- Defined in:
- lib/subscene/subtitle_result.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#comment ⇒ Object
Returns the value of attribute comment.
-
#files_count ⇒ Object
Returns the value of attribute files_count.
-
#hearing_impaired ⇒ Object
Returns the value of attribute hearing_impaired.
-
#id ⇒ Object
Returns the value of attribute id.
-
#lang ⇒ Object
Returns the value of attribute lang.
-
#name ⇒ Object
Returns the value of attribute name.
-
#url ⇒ Object
Returns the value of attribute url.
-
#user ⇒ Object
Returns the value of attribute user.
-
#user_id ⇒ Object
Returns the value of attribute user_id.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes) ⇒ SubtitleResult
constructor
A new instance of SubtitleResult.
Constructor Details
#initialize(attributes) ⇒ SubtitleResult
Returns a new instance of SubtitleResult.
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/subscene/subtitle_result.rb', line 6 def initialize(attributes) @attributes = attributes @id = @attributes[:id] @name = @attributes[:name] @url = @attributes[:url] @lang = @attributes[:lang] @user = @attributes[:user] @user_id = @attributes[:user_id] @comment = @attributes[:comment] @files_count = @attributes[:files_count] @hearing_impaired = @attributes[:hearing_impaired] end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
3 4 5 |
# File 'lib/subscene/subtitle_result.rb', line 3 def attributes @attributes end |
#comment ⇒ Object
Returns the value of attribute comment.
3 4 5 |
# File 'lib/subscene/subtitle_result.rb', line 3 def comment @comment end |
#files_count ⇒ Object
Returns the value of attribute files_count.
3 4 5 |
# File 'lib/subscene/subtitle_result.rb', line 3 def files_count @files_count end |
#hearing_impaired ⇒ Object
Returns the value of attribute hearing_impaired.
3 4 5 |
# File 'lib/subscene/subtitle_result.rb', line 3 def hearing_impaired @hearing_impaired end |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'lib/subscene/subtitle_result.rb', line 3 def id @id end |
#lang ⇒ Object
Returns the value of attribute lang.
3 4 5 |
# File 'lib/subscene/subtitle_result.rb', line 3 def lang @lang end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/subscene/subtitle_result.rb', line 3 def name @name end |
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/subscene/subtitle_result.rb', line 3 def url @url end |
#user ⇒ Object
Returns the value of attribute user.
3 4 5 |
# File 'lib/subscene/subtitle_result.rb', line 3 def user @user end |
#user_id ⇒ Object
Returns the value of attribute user_id.
3 4 5 |
# File 'lib/subscene/subtitle_result.rb', line 3 def user_id @user_id end |
Class Method Details
.build(html) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/subscene/subtitle_result.rb', line 20 def self.build(html) subtitle_url = (html.css("td.a1 a").attribute("href").value rescue nil) new({ id: (subtitle_url.match(/\d+$/).to_s rescue nil), name: (html.css("td.a1 span[2]").text.strip rescue nil), url: subtitle_url, lang: (html.css("td.a1 span[1]").text.strip rescue nil), user: (html.css("td.a5").text.strip rescue nil), user_id: (html.css("td.a5 a").attribute("href").value.match(/\d+/).to_s rescue nil), comment: (html.css("td.a6").text.strip rescue nil), files_count: (html.css("td.a3").text.to_i rescue nil), hearing_impaired: html.at_css("td.a40").nil? }) end |