Sha256: 408fc283157f85b4a028a6d861240c2120988e53ccb2500052bb1fc198d6809b
Contents?: true
Size: 1.54 KB
Versions: 3
Compression:
Stored size: 1.54 KB
Contents
require_relative 'arg_loader' require_relative 'xywh_shorthands' module Squib::Args module_function def extract_scale_box(opts, deck) ScaleBox.new.extract!(opts, deck) end class ScaleBox include ArgLoader include XYWHShorthands def self.parameters { x: 0, y: 0, width: :native, height: :native } end def self.expanding_parameters parameters.keys # all of them end def self.params_with_units parameters.keys # all of them end def validate_x(arg, i) apply_shorthands(arg, @deck, axis: :x) end def validate_y(arg,_i) apply_shorthands(arg, @deck, axis: :y) end def validate_width(arg, i) return @deck.width if arg.to_s == 'deck' return :native if arg.to_s == 'native' arg = apply_shorthands(arg, @deck, axis: :x) return arg if arg.respond_to? :to_f if arg.to_s == 'scale' raise 'if width is :scale, height must be a number' unless height[i].respond_to? :to_f return arg end raise 'width must be a number, :scale, :native, or :deck' end def validate_height(arg, i) return @deck.height if arg.to_s == 'deck' return :native if arg.to_s == 'native' arg = apply_shorthands(arg, @deck, axis: :y) return arg if arg.respond_to? :to_f if arg.to_s == 'scale' raise 'if height is \'scale\', width must be a number' unless width[i].respond_to? :to_f return arg end raise 'height must be a number, :scale, :native, or :deck' end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
squib-0.19.0 | lib/squib/args/scale_box.rb |
squib-0.19.0b | lib/squib/args/scale_box.rb |
squib-0.19.0a | lib/squib/args/scale_box.rb |