class Wikidata::Property::CommonsMedia
Constants
- BASE_PAGE_URL
- IMAGE_URL
- THUMB_IMAGE_URL
Public Instance Methods
basename()
click to toggle source
# File lib/wikidata/property/commons_media.rb, line 24 def basename @_basename ||= name.gsub ' ', '_' end
extension()
click to toggle source
# File lib/wikidata/property/commons_media.rb, line 36 def extension @_ext ||= File.extname(value).tr '.', '' end
md5()
click to toggle source
# File lib/wikidata/property/commons_media.rb, line 20 def md5 @_md5 ||= Digest::MD5.hexdigest "#{basename}.#{extension}" end
name()
click to toggle source
# File lib/wikidata/property/commons_media.rb, line 28 def name @_name ||= File.basename(value, ".#{extension}") end
page_url()
click to toggle source
# File lib/wikidata/property/commons_media.rb, line 8 def page_url @_page_url ||= sprintf BASE_PAGE_URL, basename, extension end
thumb_extension()
click to toggle source
# File lib/wikidata/property/commons_media.rb, line 32 def thumb_extension @_thumb_ext ||= extension == 'svg' ? 'svg.png' : extension end
url(size = nil)
click to toggle source
# File lib/wikidata/property/commons_media.rb, line 12 def url size = nil if size sprintf THUMB_IMAGE_URL, md5[0], md5[0..1], basename, extension, size, basename, extension, thumb_extension else sprintf IMAGE_URL, md5[0], md5[0..1], basename, extension end end