class DarujmeCz::Project

@see www.darujme.cz/doc/api/v1/index.html#endpoint-get-project-projectid

Public Class Methods

endpoint() click to toggle source
# File lib/darujme_cz/project.rb, line 5
def self.endpoint
  "project"
end
find(id) click to toggle source
# File lib/darujme_cz/project.rb, line 9
def self.find(id)
  data = connection.get "project/#{id}"
  new data[endpoint]
end
new(attributes) click to toggle source

@param [Hash] attributes

Calls superclass method DarujmeCz::Base::new
# File lib/darujme_cz/project.rb, line 15
def initialize(attributes)
  @id = attributes["projectId"]
  super
end

Public Instance Methods

content(lang = "cs") click to toggle source
# File lib/darujme_cz/project.rb, line 28
def content(lang = "cs")
  get_localized_attribute "content", lang
end
name(lang = "cs") click to toggle source
# File lib/darujme_cz/project.rb, line 20
def name(lang = "cs")
  get_localized_attribute "title", lang
end
organization() click to toggle source
# File lib/darujme_cz/project.rb, line 24
def organization
  # TODO
end
synopsis(lang = "cs") click to toggle source
# File lib/darujme_cz/project.rb, line 32
def synopsis(lang = "cs")
  get_localized_attribute "synopsis", lang
end

Private Instance Methods

get_localized_attribute(attribute, lang) click to toggle source
# File lib/darujme_cz/project.rb, line 38
def get_localized_attribute(attribute, lang)
  value = @source[attribute]
  if value.is_a?(Hash)
    value[lang] || value.values.first
  else
    value
  end
end