class CreativeCommonsRails::LicenseInfo
Attributes
jurisdiction[RW]
type[RW]
version[RW]
Public Class Methods
available_jurisdictions()
click to toggle source
# File lib/creative_commons_rails/license_info.rb, line 19 def self.available_jurisdictions license_index.keys end
available_types(jurisdiction)
click to toggle source
# File lib/creative_commons_rails/license_info.rb, line 23 def self.available_types(jurisdiction) license_index[jurisdiction.to_s].keys end
available_versions(jurisdiction, type)
click to toggle source
# File lib/creative_commons_rails/license_info.rb, line 27 def self.available_versions(jurisdiction, type) license_index[jurisdiction].select{|k,v| v[type]}.keys end
find(attributes = {})
click to toggle source
ensure the license exists in the license index
# File lib/creative_commons_rails/license_info.rb, line 8 def self.find(attributes = {}) index = license_index [:jurisdiction, :version, :type].each do |key| raise "You must specify the #{attr} to find a licence" if attributes[key].nil? index = index[attributes[key].to_s] raise "Unknown license #{key}: #{attributes[key]}" if index.nil? || !index end LicenseInfo.new(attributes[:type],attributes[:jurisdiction],attributes[:version]) end
new(type, jurisdiction, version)
click to toggle source
# File lib/creative_commons_rails/license_info.rb, line 31 def initialize(type, jurisdiction, version) @type, @jurisdiction, @version = type, jurisdiction, version end
Private Class Methods
license_index()
click to toggle source
# File lib/creative_commons_rails/license_info.rb, line 60 def self.license_index gem_root = Gem::Specification.find_by_name("creative_commons_rails").gem_dir @index ||= YAML.load_file("#{gem_root}/config/license_list.yaml") end
Public Instance Methods
deed_url()
click to toggle source
# File lib/creative_commons_rails/license_info.rb, line 35 def deed_url if jurisdiction == "unported" "http://creativecommons.org/licenses/#{type}/#{version}/deed.#{language}" else "http://creativecommons.org/licenses/#{type}/#{version}/#{jurisdiction}/deed.#{language}" end end
icon_url(size = :normal)
click to toggle source
# File lib/creative_commons_rails/license_info.rb, line 43 def icon_url(size = :normal) "http://i.creativecommons.org/l/#{type}/#{version}/#{size == :compact ? '80x15' : '88x31'}.png" end
language()
click to toggle source
# File lib/creative_commons_rails/license_info.rb, line 55 def language I18n.locale end
translated_title()
click to toggle source
# File lib/creative_commons_rails/license_info.rb, line 47 def translated_title I18n.t :license_title, license_type: translated_type end
translated_type()
click to toggle source
# File lib/creative_commons_rails/license_info.rb, line 51 def translated_type I18n.t "license_type_#{type}", version: version, jurisdiction: I18n.t(jurisdiction) end