Class: Kuler::Theme
- Inherits:
-
Object
- Object
- Kuler::Theme
- Defined in:
- lib/kuler/theme.rb
Instance Attribute Summary collapse
-
#author_id ⇒ Object
readonly
the Kuler ID for the theme’s creator.
-
#author_name ⇒ Object
readonly
the display name of the theme’s creator.
-
#rating ⇒ Object
readonly
theme rating, 1-5.
-
#swatches ⇒ Object
readonly
an array of Kuler::Swatch objects representing the colors in this theme.
-
#tags ⇒ Object
readonly
array of tags attached to this theme.
-
#theme_id ⇒ Object
readonly
the Kuler ID for the theme.
-
#title ⇒ Object
readonly
the title of the theme.
Instance Method Summary collapse
-
#hex_codes ⇒ Object
returns an array of hex values of the swatches in this theme.
-
#initialize(input) ⇒ Theme
constructor
create a new Kuler::Theme from a Nokogiri::XML::Element.
Constructor Details
#initialize(input) ⇒ Theme
create a new Kuler::Theme from a Nokogiri::XML::Element
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/kuler/theme.rb', line 28 def initialize( input ) @theme_id = input.at( "//kuler:themeID" ).text.to_i @title = input.at( "//kuler:themeTitle" ).text @tags = input.at( "//kuler:themeTags" ).text.gsub(/\s/, '').split(',') @rating = input.at( "//kuler:themeRating" ).text.to_i @author_name = input.at( "//kuler:themeAuthor/kuler:authorLabel" ).text @author_id = input.at( "//kuler:themeAuthor/kuler:authorID" ).text.to_i @swatches = input.search( "//kuler:swatch" ).map {|nodes| Kuler::Swatch.new nodes } end |
Instance Attribute Details
#author_id ⇒ Object (readonly)
the Kuler ID for the theme’s creator
20 21 22 |
# File 'lib/kuler/theme.rb', line 20 def @author_id end |
#author_name ⇒ Object (readonly)
the display name of the theme’s creator
17 18 19 |
# File 'lib/kuler/theme.rb', line 17 def @author_name end |
#rating ⇒ Object (readonly)
theme rating, 1-5
14 15 16 |
# File 'lib/kuler/theme.rb', line 14 def @rating end |
#swatches ⇒ Object (readonly)
an array of Kuler::Swatch objects representing the colors in this theme
24 25 26 |
# File 'lib/kuler/theme.rb', line 24 def swatches @swatches end |
#tags ⇒ Object (readonly)
array of tags attached to this theme
11 12 13 |
# File 'lib/kuler/theme.rb', line 11 def @tags end |
#theme_id ⇒ Object (readonly)
the Kuler ID for the theme
5 6 7 |
# File 'lib/kuler/theme.rb', line 5 def theme_id @theme_id end |
#title ⇒ Object (readonly)
the title of the theme
8 9 10 |
# File 'lib/kuler/theme.rb', line 8 def title @title end |
Instance Method Details
#hex_codes ⇒ Object
returns an array of hex values of the swatches in this theme
42 43 44 |
# File 'lib/kuler/theme.rb', line 42 def hex_codes self.swatches.map {|s| s.hex_code } end |