Class: Emf::Model::Emr::Header

Inherits:
Object
  • Object
show all
Defined in:
lib/emf/model/emr/header.rb

Overview

EMF metafile header. Preserves all wire fields verbatim so the serializer can round-trip byte-faithfully.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bounds:, frame:, signature:, version:, n_bytes:, n_records:, n_handles:, s_reserved:, n_description:, off_description:, n_pal_entries:, device_pixels:, device_mm:, cb_pixel_format:, off_pixel_format:, b_open_gl:, szl_micrometers:, n_size: 100, trailing: +"",, description: nil) ⇒ Header

Returns a new instance of Header.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/emf/model/emr/header.rb', line 9

def initialize(bounds:, frame:, signature:, version:, n_bytes:, n_records:,
               n_handles:, s_reserved:, n_description:, off_description:,
               n_pal_entries:, device_pixels:, device_mm:, cb_pixel_format:,
               off_pixel_format:, b_open_gl:, szl_micrometers:,
               n_size: 100, trailing: +"", description: nil)
  @bounds = bounds
  @frame = frame
  @signature = signature
  @version = version
  @n_bytes = n_bytes
  @n_records = n_records
  @n_handles = n_handles
  @s_reserved = s_reserved
  @n_description = n_description
  @off_description = off_description
  @n_pal_entries = n_pal_entries
  @device_pixels = device_pixels
  @device_mm = device_mm
  @cb_pixel_format = cb_pixel_format
  @off_pixel_format = off_pixel_format
  @b_open_gl = b_open_gl
  @szl_micrometers = szl_micrometers
  @n_size = n_size
  @trailing = trailing
  @description = description
end

Instance Attribute Details

#b_open_glObject (readonly)

Returns the value of attribute b_open_gl.



36
37
38
# File 'lib/emf/model/emr/header.rb', line 36

def b_open_gl
  @b_open_gl
end

#boundsObject (readonly)

Returns the value of attribute bounds.



36
37
38
# File 'lib/emf/model/emr/header.rb', line 36

def bounds
  @bounds
end

#cb_pixel_formatObject (readonly)

Returns the value of attribute cb_pixel_format.



36
37
38
# File 'lib/emf/model/emr/header.rb', line 36

def cb_pixel_format
  @cb_pixel_format
end

#descriptionObject (readonly)

Returns the value of attribute description.



36
37
38
# File 'lib/emf/model/emr/header.rb', line 36

def description
  @description
end

#device_mmObject (readonly)

Returns the value of attribute device_mm.



36
37
38
# File 'lib/emf/model/emr/header.rb', line 36

def device_mm
  @device_mm
end

#device_pixelsObject (readonly)

Returns the value of attribute device_pixels.



36
37
38
# File 'lib/emf/model/emr/header.rb', line 36

def device_pixels
  @device_pixels
end

#frameObject (readonly)

Returns the value of attribute frame.



36
37
38
# File 'lib/emf/model/emr/header.rb', line 36

def frame
  @frame
end

#n_bytesObject (readonly)

Returns the value of attribute n_bytes.



36
37
38
# File 'lib/emf/model/emr/header.rb', line 36

def n_bytes
  @n_bytes
end

#n_descriptionObject (readonly)

Returns the value of attribute n_description.



36
37
38
# File 'lib/emf/model/emr/header.rb', line 36

def n_description
  @n_description
end

#n_handlesObject (readonly)

Returns the value of attribute n_handles.



36
37
38
# File 'lib/emf/model/emr/header.rb', line 36

def n_handles
  @n_handles
end

#n_pal_entriesObject (readonly)

Returns the value of attribute n_pal_entries.



36
37
38
# File 'lib/emf/model/emr/header.rb', line 36

def n_pal_entries
  @n_pal_entries
end

#n_recordsObject (readonly)

Returns the value of attribute n_records.



36
37
38
# File 'lib/emf/model/emr/header.rb', line 36

def n_records
  @n_records
end

#n_sizeObject (readonly)

Returns the value of attribute n_size.



36
37
38
# File 'lib/emf/model/emr/header.rb', line 36

def n_size
  @n_size
end

#off_descriptionObject (readonly)

Returns the value of attribute off_description.



36
37
38
# File 'lib/emf/model/emr/header.rb', line 36

def off_description
  @off_description
end

#off_pixel_formatObject (readonly)

Returns the value of attribute off_pixel_format.



36
37
38
# File 'lib/emf/model/emr/header.rb', line 36

def off_pixel_format
  @off_pixel_format
end

#s_reservedObject (readonly)

Returns the value of attribute s_reserved.



36
37
38
# File 'lib/emf/model/emr/header.rb', line 36

def s_reserved
  @s_reserved
end

#signatureObject (readonly)

Returns the value of attribute signature.



36
37
38
# File 'lib/emf/model/emr/header.rb', line 36

def signature
  @signature
end

#szl_micrometersObject (readonly)

Returns the value of attribute szl_micrometers.



36
37
38
# File 'lib/emf/model/emr/header.rb', line 36

def szl_micrometers
  @szl_micrometers
end

#trailingObject (readonly)

Returns the value of attribute trailing.



36
37
38
# File 'lib/emf/model/emr/header.rb', line 36

def trailing
  @trailing
end

#versionObject (readonly)

Returns the value of attribute version.



36
37
38
# File 'lib/emf/model/emr/header.rb', line 36

def version
  @version
end

Class Method Details

.from_wire(wire) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/emf/model/emr/header.rb', line 42

def self.from_wire(wire)
  new(
    bounds: Geometry::Rect.from_wire(wire.rcl_bounds),
    frame: Geometry::Rect.from_wire(wire.rcl_frame),
    signature: wire.d_signature,
    version: wire.n_version,
    n_bytes: wire.n_bytes,
    n_records: wire.n_records,
    n_handles: wire.n_handles,
    s_reserved: wire.s_reserved,
    n_description: wire.n_description,
    off_description: wire.off_description,
    n_pal_entries: wire.n_pal_entries,
    device_pixels: Geometry::Size.from_wire(wire.szl_device),
    device_mm: Geometry::Size.from_wire(wire.szl_millimeters),
    cb_pixel_format: wire.cb_pixel_format,
    off_pixel_format: wire.off_pixel_format,
    b_open_gl: wire.b_open_gl,
    szl_micrometers: Geometry::Size.from_wire(wire.szl_micrometers),
    n_size: wire.n_size,
    trailing: wire.trailing.to_s
  )
end

Instance Method Details

#to_wireObject



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/emf/model/emr/header.rb', line 66

def to_wire
  Emf::Emr::Binary::Header.new(
    i_type: 1,
    n_size: n_size,
    rcl_bounds: bounds.to_wire,
    rcl_frame: frame.to_wire,
    d_signature: signature,
    n_version: version,
    n_bytes: n_bytes,
    n_records: n_records,
    n_handles: n_handles,
    s_reserved: s_reserved,
    n_description: n_description,
    off_description: off_description,
    n_pal_entries: n_pal_entries,
    szl_device: device_pixels.to_wire,
    szl_millimeters: device_mm.to_wire,
    cb_pixel_format: cb_pixel_format,
    off_pixel_format: off_pixel_format,
    b_open_gl: b_open_gl,
    szl_micrometers: szl_micrometers.to_wire,
    trailing: trailing
  )
end