class Inkmake::InkscapeUnit
Constants
- Units
90dpi as reference
Attributes
unit[R]
value[R]
Public Class Methods
new(value, unit="uu")
click to toggle source
# File lib/inkmake.rb, line 70 def initialize(value, unit="uu") case value when /^(\d+(?:\.\d+)?)(\w+)?$/ then @value = $1.to_f @unit = $2 @unit ||= unit @unit = (@unit == "px" or Units.has_key?(@unit)) ? @unit : "uu" else @value = value.kind_of?(String) ? value.to_f: value @unit = unit end end
Public Instance Methods
scale(f)
click to toggle source
# File lib/inkmake.rb, line 92 def scale(f) return self if @unit == "px" InkscapeUnit.new(@value * f, @unit) end
to_pixels(dpi=90.0)
click to toggle source
# File lib/inkmake.rb, line 83 def to_pixels(dpi=90.0) return @value.round if @unit == "px" ((dpi / 90.0) * Units[@unit] * @value).round end
to_s()
click to toggle source
# File lib/inkmake.rb, line 88 def to_s "%g#{@unit}" % @value end