Sha256: 28eb30f0724eaf6da577b05276a0c15bb76e4c8283ff56bc973133ca840488e4

Contents?: true

Size: 1.25 KB

Versions: 6

Compression:

Stored size: 1.25 KB

Contents

module Postdoc
  # Different prints require different settings. This class is used instead of
  # passing options arguments throughout all of the code.
  class PrintSettings

    attr_accessor :slow_pc

    def initialize(
        header_template: '',
        footer_template: '',
        landscape: false,
        print_background: true,
        margin_top: 1,
        margin_bottom: 1,
        margin_left: 1,
        margin_right: 1,
        slow_pc: false
    )
      @header_template = header_template
      @footer_template = footer_template
      @landscape = landscape
      @print_background = print_background
      @margin_top = margin_top
      @margin_bottom = margin_bottom
      @margin_left = margin_left
      @margin_right = margin_right
      @slow_pc = slow_pc
    end

    def to_cmd
      { landscape: @landscape,
        printBackground: true,
        marginTop: @margin_top,
        marginBottom: @margin_bottom,
        marginLeft: @margin_left,
        marginRight: @margin_right,
        displayHeaderFooter: display_header_and_footer?,
        headerTemplate: @header_template,
        footerTemplate: @footer_template }
    end

    private

    def display_header_and_footer?
      @header_template.present? || @footer_template.present?
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
postdoc-0.5.0 lib/postdoc/print_settings.rb
postdoc-0.4.5 lib/postdoc/print_settings.rb
postdoc-0.4.4 lib/postdoc/print_settings.rb
postdoc-0.4.3 lib/postdoc/print_settings.rb
postdoc-0.4.2 lib/postdoc/print_settings.rb
postdoc-0.4.1 lib/postdoc/print_settings.rb