Refactoring and documentation
parent
574f99af12
commit
0da51b4573
|
|
@ -54,7 +54,7 @@ module Squib
|
|||
# data = csv file: 'data.csv'
|
||||
# => {'h1' => [1,3], 'h2' => [2,4]}
|
||||
#
|
||||
# Parsing uses Ruby's CSV, options: {headers: true, converters: :numeric}
|
||||
# Parsing uses Ruby's CSV, with options `{headers: true, converters: :numeric}`
|
||||
# http://www.ruby-doc.org/stdlib-2.0/libdoc/csv/rdoc/CSV.html
|
||||
#
|
||||
# @option opts file [String] the CSV-formatted file to open. Opens relative to the current directory.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
require 'squib/constants'
|
||||
|
||||
module Squib
|
||||
class Deck
|
||||
|
||||
|
|
@ -13,7 +15,6 @@ module Squib
|
|||
@dpi * n.to_f
|
||||
end
|
||||
|
||||
@@INCHES_IN_CM = 0.393700787
|
||||
# Given cm, returns the number of pixels according to the deck's DPI.
|
||||
#
|
||||
# @example
|
||||
|
|
@ -23,7 +24,7 @@ module Squib
|
|||
# @return [Decimal] the number of pixels, according to the deck's DPI
|
||||
# @api public
|
||||
def cm(n)
|
||||
@dpi * @@INCHES_IN_CM * n.to_f
|
||||
@dpi * Squib::INCHES_IN_CM * n.to_f
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -22,6 +22,9 @@ module Squib
|
|||
@cairo_context = Cairo::Context.new(@cairo_surface)
|
||||
end
|
||||
|
||||
# A save/restore wrapper for using Cairo
|
||||
# :nodoc:
|
||||
# @api private
|
||||
def use_cairo(&block)
|
||||
@cairo_context.save
|
||||
block.yield(@cairo_context)
|
||||
|
|
|
|||
|
|
@ -134,4 +134,9 @@ module Squib
|
|||
:y3 => :y3,
|
||||
:y_radius => :y_radius,
|
||||
}
|
||||
|
||||
# Used for inch-cm conversion
|
||||
# :nodoc:
|
||||
# @api private
|
||||
INCHES_IN_CM = 0.393700787
|
||||
end
|
||||
|
|
|
|||
|
|
@ -169,6 +169,9 @@ module Squib
|
|||
end
|
||||
end
|
||||
|
||||
# Use Logger to show more detail on the run
|
||||
# :nodoc:
|
||||
# @api private
|
||||
def show_info(config, layout)
|
||||
Squib::logger.info "Squib v#{Squib::VERSION}"
|
||||
Squib::logger.info " building #{@cards.size} #{@width}x#{@height} cards"
|
||||
|
|
|
|||
|
|
@ -95,8 +95,8 @@ module Squib
|
|||
#
|
||||
# @param surface The surface to trim
|
||||
# @param trim The number of pixels around the edge to trim
|
||||
# @width width The width of the surface prior to the trim
|
||||
# @height height The height of the surface prior to the trim
|
||||
# @param width The width of the surface prior to the trim
|
||||
# @param height The height of the surface prior to the trim
|
||||
# :nodoc:
|
||||
# @api private
|
||||
def trim(surface, trim, width, height)
|
||||
|
|
|
|||
|
|
@ -192,7 +192,6 @@ module Squib
|
|||
end
|
||||
module_function :rotateify
|
||||
|
||||
@@INCHES_IN_CM = 0.393700787
|
||||
# Convert units
|
||||
# :nodoc:
|
||||
# @api private
|
||||
|
|
@ -204,7 +203,7 @@ module Squib
|
|||
when /in$/ #ends with "in"
|
||||
opts[api_param][i] = arg.rstrip[0..-2].to_f * @dpi
|
||||
when /cm$/ #ends with "cm"
|
||||
opts[api_param][i] = arg.rstrip[0..-2].to_f * @dpi * @@INCHES_IN_CM
|
||||
opts[api_param][i] = arg.rstrip[0..-2].to_f * @dpi * Squib::INCHES_IN_CM
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -226,7 +225,5 @@ module Squib
|
|||
opts
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue