Module: PJL

Included in:
PjlAppl
Defined in:
lib/pjl.rb,
lib/pjl/version.rb

Overview

pjl/version.rb – Name and version number

Defined Under Namespace

Classes: Cmd

Constant Summary collapse

NAME =
"pjl"
VERSION =
"1.3".freeze
SUMMARY =
"PJL generation"
DESCRIPTION =
<<EOT
Write PJL (Printer Job Language) commands from a Ruby program.
EOT
"(C) 2013-2020 Bertram Scharpf"
LICENSE =
"BSD-2-Clause"
AUTHOR =
"Bertram Scharpf <[email protected]>"
TEAM =
[ "Bertram Scharpf"]
HOMEPAGE =
"http://www.bertram-scharpf.de/software/pjl"

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, **kwargs, &block) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/pjl.rb', line 80

def method_missing name, *args, **kwargs, &block
  if block then
    super
  else
    args.each { |a|
      case a
        when String, Symbol then next
        else                     super
      end
    }
    if name.to_s =~ /\Apjl_/ then name = $'.to_sym end
    pjl name, *args, **kwargs
  end
end

Instance Method Details

#enter(language) ⇒ Object



95
96
97
98
99
100
101
# File 'lib/pjl.rb', line 95

def enter language
  pjl :enter, language: language.to_sym
  yield
ensure
  uel
  pjl
end

#iparm(p) ⇒ Object



67
68
69
70
71
72
73
# File 'lib/pjl.rb', line 67

def iparm p
  m = @m
  @m = { iparm: p.to_sym }
  yield
ensure
  @m = m
end

#job(name, **kwargs) ⇒ Object



48
49
50
51
52
53
54
55
56
57
# File 'lib/pjl.rb', line 48

def job name, **kwargs
  print "\0"*32
  uels do
    pjl
    pjl :job, name: name, **kwargs
    yield
  ensure
    pjl :eoj, name: name
  end
end

#lparm(p) ⇒ Object



59
60
61
62
63
64
65
# File 'lib/pjl.rb', line 59

def lparm p
  m = @m
  @m = { lparm: p.to_sym }
  yield
ensure
  @m = m
end

#noopObject Also known as: nop



75
76
77
# File 'lib/pjl.rb', line 75

def noop
  pjl
end