Class: Magick::RVG::Styles
- Inherits:
-
Struct
- Object
- Struct
- Magick::RVG::Styles
- Defined in:
- lib/rvg/stylable.rb,
lib/rvg/stylable.rb
Overview
Styles is a Struct class with a couple of extra methods
Instance Method Summary collapse
-
#deep_copy(_h = nil) ⇒ Object
The “usual” deep_copy method doesn’t copy a Struct correctly.
-
#each_value ⇒ Object
Iterate over the style names.
- #set(styles) ⇒ Object
Instance Method Details
#deep_copy(_h = nil) ⇒ Object
The “usual” deep_copy method doesn’t copy a Struct correctly.
45 46 47 48 49 |
# File 'lib/rvg/stylable.rb', line 45 def deep_copy(_h = nil) copy = Styles.new each_pair { |style, value| copy[style] = value } copy end |
#each_value ⇒ Object
Iterate over the style names. Yield for each style that has a value.
38 39 40 41 42 |
# File 'lib/rvg/stylable.rb', line 38 def each_value each_pair do |style, value| yield(style, value) if value end end |
#set(styles) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rvg/stylable.rb', line 22 def set(styles) begin styles.each_pair do |style, value| begin self[style] = value rescue NoMethodError raise ArgumentError, "unknown style `#{style}'" end end rescue NoMethodError raise ArgumentError, "style arguments must be in the form `style => value'" end self end |