Sha256: 6ef43ca85cefbc341d780a449cc7d23856be654a4acc8bf206e82825d290319d
Contents?: true
Size: 1.59 KB
Versions: 3
Compression:
Stored size: 1.59 KB
Contents
require_relative '../args/box' require_relative '../args/card_range' require_relative '../args/draw' require_relative '../args/paragraph' require_relative '../args/transform' require_relative '../dsl/text_embed' require_relative '../errors_warnings/warn_unexpected_params' module Squib class Deck def text(opts = {}) embed = TextEmbed.new self, __callee__ yield(embed) if block_given? # store the opts for later use DSL::Text.new(self, __callee__, embed).run(opts) end end module DSL class Text include WarnUnexpectedParams attr_reader :dsl_method, :deck, :embed def initialize(deck, dsl_method, embed) @deck = deck @dsl_method = dsl_method @embed = embed end def self.accepted_params %i( str font font_size x y markup width height wrap spacing align justify valign ellipsize angle dash cap join hint color fill_color stroke_color stroke_width stroke_width stroke_color stroke_strategy range layout ) end def run(opts) warn_if_unexpected opts range = Args.extract_range opts, deck para = Args.extract_para opts, deck box = Args.extract_box opts, deck, { width: :auto, height: :auto } trans = Args.extract_transform opts, deck draw = Args.extract_draw opts, deck, { stroke_width: 0.0 } extents = Array.new(deck.size) range.each do |i| extents[i] = deck.cards[i].text(embed, para[i], box[i], trans[i], draw[i], deck.dpi) end return extents end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
squib-0.19.0 | lib/squib/dsl/text.rb |
squib-0.19.0b | lib/squib/dsl/text.rb |
squib-0.19.0a | lib/squib/dsl/text.rb |