Class: Camdram::Search

Inherits:
Base
  • Object
show all
Includes:
API
Defined in:
lib/camdram/search.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#id

Instance Method Summary collapse

Methods inherited from Base

#make_orphan

Constructor Details

#initialize(*args) ⇒ Camdram::Search

Instantiate a new Search object from a JSON hash

Parameters:

  • options (Hash)

    A single JSON hash with symbolized keys.


19
20
21
22
23
# File 'lib/camdram/search.rb', line 19

def initialize(*args)
  super(*args)
  @start_at = Date.parse(@start_at) unless @start_at.nil?
  @last_active = Date.parse(@last_active) unless @last_active.nil?
end

Instance Attribute Details

#entity_typeObject

Returns the value of attribute entity_type


13
14
15
# File 'lib/camdram/search.rb', line 13

def entity_type
  @entity_type
end

#last_activeObject

Returns the value of attribute last_active


13
14
15
# File 'lib/camdram/search.rb', line 13

def last_active
  @last_active
end

#nameObject

Returns the value of attribute name


13
14
15
# File 'lib/camdram/search.rb', line 13

def name
  @name
end

#rankObject

Returns the value of attribute rank


13
14
15
# File 'lib/camdram/search.rb', line 13

def rank
  @rank
end

#show_countObject

Returns the value of attribute show_count


13
14
15
# File 'lib/camdram/search.rb', line 13

def show_count
  @show_count
end

#slugObject

Returns the value of attribute slug


13
14
15
# File 'lib/camdram/search.rb', line 13

def slug
  @slug
end

#start_atObject

Returns the value of attribute start_at


13
14
15
# File 'lib/camdram/search.rb', line 13

def start_at
  @start_at
end

Instance Method Details

#entityObject

Return the correct Ruby object referenced by the search entity

Returns:

  • (Object)

    The Ruby object that is referenced by the search entity.


28
29
30
31
32
33
34
35
36
37
38
# File 'lib/camdram/search.rb', line 28

def entity
  klass = case entity_type
    when "show" then Show
    when "society" then Society
    when "venue" then Venue
    when "person" then Person
  end
  url = "#{klass.url}/#{slug}.json"
  response = get(url)
  return klass.new(response, @client_instance)
end

#infoHash

Return a hash of the search entity's attributes

Returns:

  • (Hash)

    Hash with symbolized keys.


43
44
45
46
47
48
49
50
51
52
# File 'lib/camdram/search.rb', line 43

def info
  {
    name: name,
    slug: slug,
    start_at: start_at,
    rank: rank,
    id: id,
    entity_type: entity_type,
  }
end