Class: Redmine::Themes::Theme

Inherits:
Object
  • Object
show all
Defined in:
lib/redmine/themes.rb

Overview

Class used to represent a theme

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Theme

Returns a new instance of Theme.



47
48
49
50
51
52
53
# File 'lib/redmine/themes.rb', line 47

def initialize(path)
  @path = path
  @dir = File.basename(path)
  @name = @dir.humanize
  @stylesheets = nil
  @javascripts = nil
end

Instance Attribute Details

#dirObject (readonly)

Returns the value of attribute dir.



45
46
47
# File 'lib/redmine/themes.rb', line 45

def dir
  @dir
end

#nameObject (readonly)

Returns the value of attribute name.



45
46
47
# File 'lib/redmine/themes.rb', line 45

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



45
46
47
# File 'lib/redmine/themes.rb', line 45

def path
  @path
end

Instance Method Details

#<=>(theme) ⇒ Object



62
63
64
# File 'lib/redmine/themes.rb', line 62

def <=>(theme)
  name <=> theme.name
end

#==(theme) ⇒ Object



58
59
60
# File 'lib/redmine/themes.rb', line 58

def ==(theme)
  theme.is_a?(Theme) && theme.dir == dir
end

#idObject

Directory name used as the theme id



56
# File 'lib/redmine/themes.rb', line 56

def id; dir end

#javascript_path(source) ⇒ Object



78
79
80
# File 'lib/redmine/themes.rb', line 78

def javascript_path(source)
  "/themes/#{dir}/javascripts/#{source}"
end

#javascriptsObject



70
71
72
# File 'lib/redmine/themes.rb', line 70

def javascripts
  @javascripts ||= assets("javascripts", "js")
end

#stylesheet_path(source) ⇒ Object



74
75
76
# File 'lib/redmine/themes.rb', line 74

def stylesheet_path(source)
  "/themes/#{dir}/stylesheets/#{source}"
end

#stylesheetsObject



66
67
68
# File 'lib/redmine/themes.rb', line 66

def stylesheets
  @stylesheets ||= assets("stylesheets", "css")
end