Class: PBRT::Spectrum

Inherits:
Object
  • Object
show all
Defined in:
lib/pbrt/spectrum.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, *args) ⇒ Spectrum



5
6
7
8
# File 'lib/pbrt/spectrum.rb', line 5

def initialize(type, *args)
  @type = type
  @args = args
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



3
4
5
# File 'lib/pbrt/spectrum.rb', line 3

def args
  @args
end

#typeObject (readonly)

Returns the value of attribute type.



3
4
5
# File 'lib/pbrt/spectrum.rb', line 3

def type
  @type
end

Class Method Details

.check_value_is_a_spectrum(value) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/pbrt/spectrum.rb', line 16

def self.check_value_is_a_spectrum(value)
  return if value.is_a?(self)

  message = "Please specify the spectrum representation for #{value.inspect}.\n"
  message += "You can do this by wrapping the value: rgb(#{value.inspect})\n"
  message += "Valid representations are: rgb, xyz, sampled and blackbody"

  raise AmbiguousSpectrumError, message
end

.unpack(value) ⇒ Object



10
11
12
13
14
# File 'lib/pbrt/spectrum.rb', line 10

def self.unpack(value)
  check_value_is_a_spectrum(value)

  [value.type, value.args]
end