royw-imdb 0.0.11 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/README +4 -2
  2. data/lib/imdb/imdb_movie.rb +20 -0
  3. metadata +1 -1
data/README CHANGED
@@ -20,6 +20,8 @@ ImdbMovie Indiana Jones and the Last Crusade
20
20
  - should get some photos
21
21
  - should get the tagline
22
22
  - should get the aspect ratio
23
+ - should convert to xml
24
+ - should convert to yaml
23
25
 
24
26
  ImdbMovie Han robado una estrella
25
27
  - should query IMDB url
@@ -82,6 +84,6 @@ String unescape_html
82
84
  String strip_tags
83
85
  - should strip HTML tags
84
86
 
85
- Finished in 3.245587 seconds
87
+ Finished in 3.464305 seconds
86
88
 
87
- 59 examples, 0 failures
89
+ 61 examples, 0 failures
@@ -1,3 +1,6 @@
1
+ require 'yaml'
2
+ require 'xmlsimple'
3
+
1
4
  class ImdbMovie
2
5
  include Comparable
3
6
 
@@ -168,6 +171,23 @@ class ImdbMovie
168
171
  cert_hash
169
172
  end
170
173
 
174
+ def to_hash
175
+ hash = {}
176
+ [:title, :directors, :poster_url, :tiny_poster_url, :poster, :rating, :cast_members,
177
+ :writers, :year, :genres, :plot, :tagline, :aspect_ratio, :length, :release_date,
178
+ :countries, :languages, :color, :company, :photos, :raw_title, :release_year,
179
+ :also_known_as, :mpaa, :certifications].each {|sym| hash[sym.to_s] = send(sym.to_s)}
180
+ hash
181
+ end
182
+
183
+ def to_xml
184
+ XmlSimple.xml_out(to_hash, 'NoAttr' => true, 'RootName' => 'movie')
185
+ end
186
+
187
+ def to_yaml
188
+ YAML.dump(to_hash)
189
+ end
190
+
171
191
  private
172
192
 
173
193
  # def update_title
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: royw-imdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergio Gil