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.



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

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

Instance Attribute Details

#nameObject (readonly)

The name for the value.



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

def name
  @name
end

#valueObject (readonly)

The value itself.



46
47
48
# File 'lib/hexapdf/content/graphics_state.rb', line 46

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.



60
61
62
63
# File 'lib/hexapdf/content/graphics_state.rb', line 60

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

#to_operandsObject

Returns the value.



66
67
68
# File 'lib/hexapdf/content/graphics_state.rb', line 66

def to_operands
  @value
end