Class: Stylish::Image
- Inherits:
-
Object
- Object
- Stylish::Image
- Includes:
- Formattable
- Defined in:
- lib/stylish/extended.rb
Overview
Instances of the Image class are used to represent paths to images, generally background images.
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path) ⇒ Image
constructor
Image instances are serialised to URI values.
-
#to_s ⇒ Object
Serialising Image objects to a string produces the URI values seen in background-image declarations, e.g.
Methods included from Formattable
Constructor Details
#initialize(path) ⇒ Image
Image instances are serialised to URI values. The path to the image file can be surrounded by either single quotes, double quotes or neither; single quotes are the default in Stylish.
14 15 16 |
# File 'lib/stylish/extended.rb', line 14 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
8 9 10 |
# File 'lib/stylish/extended.rb', line 8 def path @path end |
Instance Method Details
#to_s ⇒ Object
Serialising Image objects to a string produces the URI values seen in background-image declarations, e.g.
image = Image.new("test.png")
image.to_s # => "url('test.png')"
background = Stylish::Background.new(:image => "test.png")
background.to_s # => "background-image:url('test.png');"
27 28 29 |
# File 'lib/stylish/extended.rb', line 27 def to_s sprintf(self.class.format, path.to_s) end |