Class: Postsvg::Svg::Stroke
- Inherits:
-
Struct
- Object
- Struct
- Postsvg::Svg::Stroke
- Defined in:
- lib/postsvg/svg/stroke.rb
Overview
Stroke style value object. Width is a Float (default 1.0), dasharray is an Array of Floats, dashoffset is a Float, linecap / linejoin are Symbols.
Instance Attribute Summary collapse
-
#dasharray ⇒ Object
Returns the value of attribute dasharray.
-
#dashoffset ⇒ Object
Returns the value of attribute dashoffset.
-
#linecap ⇒ Object
Returns the value of attribute linecap.
-
#linejoin ⇒ Object
Returns the value of attribute linejoin.
-
#miterlimit ⇒ Object
Returns the value of attribute miterlimit.
-
#width ⇒ Object
Returns the value of attribute width.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#dasharray ⇒ Object
Returns the value of attribute dasharray
8 9 10 |
# File 'lib/postsvg/svg/stroke.rb', line 8 def dasharray @dasharray end |
#dashoffset ⇒ Object
Returns the value of attribute dashoffset
8 9 10 |
# File 'lib/postsvg/svg/stroke.rb', line 8 def dashoffset @dashoffset end |
#linecap ⇒ Object
Returns the value of attribute linecap
8 9 10 |
# File 'lib/postsvg/svg/stroke.rb', line 8 def linecap @linecap end |
#linejoin ⇒ Object
Returns the value of attribute linejoin
8 9 10 |
# File 'lib/postsvg/svg/stroke.rb', line 8 def linejoin @linejoin end |
#miterlimit ⇒ Object
Returns the value of attribute miterlimit
8 9 10 |
# File 'lib/postsvg/svg/stroke.rb', line 8 def miterlimit @miterlimit end |
#width ⇒ Object
Returns the value of attribute width
8 9 10 |
# File 'lib/postsvg/svg/stroke.rb', line 8 def width @width end |
Class Method Details
.parse(node) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/postsvg/svg/stroke.rb', line 10 def self.parse(node) width = AttributeParser.number(node["stroke-width"], default: 1.0) dasharray_raw = node["stroke-dasharray"] dasharray = if dasharray_raw && dasharray_raw != "none" AttributeParser.number_list(dasharray_raw) end dashoffset = AttributeParser.number(node["stroke-dashoffset"], default: 0.0) linecap = (node["stroke-linecap"] || "butt").to_sym linejoin = (node["stroke-linejoin"] || "miter").to_sym miterlimit = AttributeParser.number(node["stroke-miterlimit"], default: 10.0) new(width: width, dasharray: dasharray, dashoffset: dashoffset, linecap: linecap, linejoin: linejoin, miterlimit: miterlimit) end |
Instance Method Details
#default? ⇒ Boolean
25 26 27 28 |
# File 'lib/postsvg/svg/stroke.rb', line 25 def default? width == 1.0 && dasharray.nil? && dashoffset.zero? && linecap == :butt && linejoin == :miter && miterlimit == 10.0 end |