Class: VSCinemas::MovieItem
- Inherits:
-
Object
- Object
- VSCinemas::MovieItem
- Defined in:
- lib/vscinemas/movie_item.rb
Overview
The Movie
Instance Attribute Summary collapse
- #element ⇒ Object readonly
Instance Method Summary collapse
-
#date ⇒ Date
Date.
-
#detail_url ⇒ URI
Detail URL.
-
#figure ⇒ URI
Figure URI.
-
#initialize(element) ⇒ MovieItem
constructor
A new instance of MovieItem.
-
#inspect ⇒ String
Inspect.
-
#title ⇒ String
Title.
-
#title_en ⇒ String
English Title.
- #to_h ⇒ Hash
Constructor Details
#initialize(element) ⇒ MovieItem
Returns a new instance of MovieItem.
14 15 16 17 18 |
# File 'lib/vscinemas/movie_item.rb', line 14 def initialize(element) @element = element @info_element = element.css('.infoArea') @tag_elements = element.css('.iconArea .theaterMark') end |
Instance Attribute Details
#element ⇒ Object (readonly)
9 10 11 |
# File 'lib/vscinemas/movie_item.rb', line 9 def element @element end |
Instance Method Details
#date ⇒ Date
Date
43 44 45 46 47 |
# File 'lib/vscinemas/movie_item.rb', line 43 def date @date ||= Date.parse(@info_element.css('time').to_s) rescue ArgumentError nil end |
#detail_url ⇒ URI
Detail URL
54 55 56 |
# File 'lib/vscinemas/movie_item.rb', line 54 def detail_url @detail_url ||= URI.join(ENDPOINT, PATH, @element.css('h2 a').attr('href').text) end |
#figure ⇒ URI
Figure URI
63 64 65 |
# File 'lib/vscinemas/movie_item.rb', line 63 def figure @figure ||= URI.join(ENDPOINT, PATH, @element.css('figure img').attr('src').text) end |
#inspect ⇒ String
Inspect
85 86 87 |
# File 'lib/vscinemas/movie_item.rb', line 85 def inspect "#<#{self.class.name} title=#{title} date=#{date}>" end |
#title ⇒ String
Title
25 26 27 |
# File 'lib/vscinemas/movie_item.rb', line 25 def title @title ||= @info_element.css('h2').text&.strip end |
#title_en ⇒ String
English Title
34 35 36 |
# File 'lib/vscinemas/movie_item.rb', line 34 def title_en @title_en ||= @info_element.css('h3').text&.strip end |
#to_h ⇒ Hash
70 71 72 73 74 75 76 77 78 |
# File 'lib/vscinemas/movie_item.rb', line 70 def to_h { title: title, title_en: title_en, date: date, detail_url: detail_url, figure: figure } end |