Class: HexaPDF::Content::NamedValue

Inherits:
Object
  • Object
show all
Defined in:
lib/hexapdf/content/graphics_state.rb

Overview

Associates a name with a value, used by various graphics state parameters.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, value) ⇒ NamedValue

Creates a new NamedValue object and freezes it.



55
56
57
58
59
# File 'lib/hexapdf/content/graphics_state.rb', line 55

def initialize(name, value)
  @name = name
  @value = value
  freeze
end

Instance Attribute Details

#nameObject (readonly)

The name for the value.



52
53
54
# File 'lib/hexapdf/content/graphics_state.rb', line 52

def name
  @name
end

#valueObject (readonly)

The value itself.



49
50
51
# File 'lib/hexapdf/content/graphics_state.rb', line 49

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object

The object is equal to other if either the name or the value is equal to other, or if the other object is a NamedValue object with the same name and value.



63
64
65
66
# File 'lib/hexapdf/content/graphics_state.rb', line 63

def ==(other)
  @name == other || @value == other ||
    (other.kind_of?(NamedValue) && @name == other.name && @value == other.value)
end

#to_operandsObject

Returns the value.



69
70
71
# File 'lib/hexapdf/content/graphics_state.rb', line 69

def to_operands
  @value
end