Class: RogerThemes::Asset

Inherits:
Object
  • Object
show all
Defined in:
lib/roger_themes/asset.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, theme) ⇒ Asset

Returns a new instance of Asset.



5
6
7
8
9
# File 'lib/roger_themes/asset.rb', line 5

def initialize(data, theme)
  @data = {}
  update(data)
  @theme = theme
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



3
4
5
# File 'lib/roger_themes/asset.rb', line 3

def data
  @data
end

#themeObject (readonly)

Returns the value of attribute theme.



3
4
5
# File 'lib/roger_themes/asset.rb', line 3

def theme
  @theme
end

Instance Method Details

#attributesObject



40
41
42
# File 'lib/roger_themes/asset.rb', line 40

def attributes
  @data["attributes"] || {}
end

#full_pathObject



24
25
26
# File 'lib/roger_themes/asset.rb', line 24

def full_path
  theme.path + path
end

#initialize_copy(source) ⇒ Object



15
16
17
# File 'lib/roger_themes/asset.rb', line 15

def initialize_copy(source)
  @data = @data.dup
end

#locationObject



32
33
34
# File 'lib/roger_themes/asset.rb', line 32

def location
  @data["location"].to_s
end

#pathObject

Relative path within theme



20
21
22
# File 'lib/roger_themes/asset.rb', line 20

def path
  @data["path"].to_s
end

#typeObject



36
37
38
# File 'lib/roger_themes/asset.rb', line 36

def type
  @data["type"].to_s
end

#update(data) ⇒ Object



11
12
13
# File 'lib/roger_themes/asset.rb', line 11

def update(data)
  @data.update(data)
end

#urlObject



28
29
30
# File 'lib/roger_themes/asset.rb', line 28

def url
  [theme.url.sub(/\/\Z/, ''), path.sub(/\A\//, '')].join("/")
end