Class: Camdram::Search

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

Instance Attribute Summary collapse

Attributes included from API

#http

Attributes inherited from Base

#id

Instance Method Summary collapse

Methods included from API

#initialize, #update!

Methods inherited from Base

#initialize

Instance Attribute Details

#entity_typeObject

Returns the value of attribute entity_type.



11
12
13
# File 'lib/camdram/search.rb', line 11

def entity_type
  @entity_type
end

#nameObject

Returns the value of attribute name.



11
12
13
# File 'lib/camdram/search.rb', line 11

def name
  @name
end

#rankObject

Returns the value of attribute rank.



11
12
13
# File 'lib/camdram/search.rb', line 11

def rank
  @rank
end

#slugObject

Returns the value of attribute slug.



11
12
13
# File 'lib/camdram/search.rb', line 11

def slug
  @slug
end

#start_atObject

Returns the value of attribute start_at.



11
12
13
# File 'lib/camdram/search.rb', line 11

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.



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/camdram/search.rb', line 16

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

#infoHash

Return a hash of the search entity's attributes

Returns:

  • (Hash)

    Hash with symbolized keys.



31
32
33
34
35
36
37
38
39
40
# File 'lib/camdram/search.rb', line 31

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