class CTioga2::Graphics::Types::BaseCoordinate
This class performs the same function as Dimension
, except that it represents a coordinate. As such, its value
only makes sense as a page, frame or figure coordinate
Public Class Methods
from_text(text, orientation, default = :figure)
click to toggle source
Creates a BaseCoordinate
object from a text specification. Takes the same argument as Dimension.from_text
, except that purely dimension type
won't be accepted.
# File lib/ctioga2/graphics/types/point.rb, line 63 def self.from_text(text, orientation, default = :figure) dim = Dimension.from_text(text, orientation, default) if dim.type == :bp or dim.type == :dy raise "Does not accept dimensions only for coordinates" end return BaseCoordinate.new(dim.type, dim.value, dim.orientation) end
new(type, value, orientation)
click to toggle source
Creates a BaseCoordinate
object of the given type, the given value and oriented along the given orientation
Calls superclass method
CTioga2::Graphics::Types::Dimension::new
# File lib/ctioga2/graphics/types/point.rb, line 30 def initialize(type, value, orientation) super end
Public Instance Methods
to_figure(t, orientation = nil)
click to toggle source
Converts the Dimension
to the figure coordinates of the current figure in t.
# File lib/ctioga2/graphics/types/point.rb, line 36 def to_figure(t, orientation = nil) orientation ||= @orientation case @type when :frame return t.send("convert_frame_to_figure_#{orientation}", @value) when :page int = t.send("convert_page_to_frame_#{orientation}", @value) return t.send("convert_frame_to_figure_#{orientation}", int) when :figure return @value else raise "Invalid type for BaseCoordinate: #{@type}" end end
to_frame(t, orientation = nil)
click to toggle source
Converts the Dimension
to the frame coordinates of the current frame in t.
# File lib/ctioga2/graphics/types/point.rb, line 53 def to_frame(t, orientation = nil) orientation ||= @orientation return t.send("convert_figure_to_frame_#{orientation}", to_figure(t, orientation)) end