Class: SpotifyWebApi::TimeIntervalObject

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/spotify_web_api/models/time_interval_object.rb

Overview

TimeIntervalObject Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(start = SKIP, duration = SKIP, confidence = SKIP) ⇒ TimeIntervalObject

Returns a new instance of TimeIntervalObject.



47
48
49
50
51
# File 'lib/spotify_web_api/models/time_interval_object.rb', line 47

def initialize(start = SKIP, duration = SKIP, confidence = SKIP)
  @start = start unless start == SKIP
  @duration = duration unless duration == SKIP
  @confidence = confidence unless confidence == SKIP
end

Instance Attribute Details

#confidenceFloat

The confidence, from 0.0 to 1.0, of the reliability of the interval.

Returns:

  • (Float)


22
23
24
# File 'lib/spotify_web_api/models/time_interval_object.rb', line 22

def confidence
  @confidence
end

#durationFloat

The duration (in seconds) of the time interval.

Returns:

  • (Float)


18
19
20
# File 'lib/spotify_web_api/models/time_interval_object.rb', line 18

def duration
  @duration
end

#startFloat

The starting point (in seconds) of the time interval.

Returns:

  • (Float)


14
15
16
# File 'lib/spotify_web_api/models/time_interval_object.rb', line 14

def start
  @start
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/spotify_web_api/models/time_interval_object.rb', line 54

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.

  start = hash.key?('start') ? hash['start'] : SKIP
  duration = hash.key?('duration') ? hash['duration'] : SKIP
  confidence = hash.key?('confidence') ? hash['confidence'] : SKIP

  # Create object from extracted values.

  TimeIntervalObject.new(start,
                         duration,
                         confidence)
end

.namesObject

A mapping from model property names to API property names.



25
26
27
28
29
30
31
# File 'lib/spotify_web_api/models/time_interval_object.rb', line 25

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['start'] = 'start'
  @_hash['duration'] = 'duration'
  @_hash['confidence'] = 'confidence'
  @_hash
end

.nullablesObject

An array for nullable fields



43
44
45
# File 'lib/spotify_web_api/models/time_interval_object.rb', line 43

def self.nullables
  []
end

.optionalsObject

An array for optional fields



34
35
36
37
38
39
40
# File 'lib/spotify_web_api/models/time_interval_object.rb', line 34

def self.optionals
  %w[
    start
    duration
    confidence
  ]
end