Class: Kinbote::Value
- Inherits:
-
Object
- Object
- Kinbote::Value
- Defined in:
- lib/kinbote/value.rb
Instance Attribute Summary collapse
-
#attribute ⇒ Object
Returns the value of attribute attribute.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #add_page(page) ⇒ Object
- #create_css ⇒ Object
- #css! ⇒ Object
- #css? ⇒ Boolean
- #css_files ⇒ Object
- #file_name(type, dir = nil) ⇒ Object
-
#initialize(value, page, attribute, global_value = nil) ⇒ Value
constructor
A new instance of Value.
- #pages ⇒ Object
- #remove_page(page) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(value, page, attribute, global_value = nil) ⇒ Value
Returns a new instance of Value.
5 6 7 8 9 10 11 |
# File 'lib/kinbote/value.rb', line 5 def initialize(value, page, attribute, global_value = nil) @value = value.to_s @attribute = attribute @global_value = global_value || self @pages = [page] @css = File.exist?(file_name(:css)) end |
Instance Attribute Details
#attribute ⇒ Object
Returns the value of attribute attribute.
3 4 5 |
# File 'lib/kinbote/value.rb', line 3 def attribute @attribute end |
#value ⇒ Object
Returns the value of attribute value.
3 4 5 |
# File 'lib/kinbote/value.rb', line 3 def value @value end |
Instance Method Details
#add_page(page) ⇒ Object
13 14 15 16 |
# File 'lib/kinbote/value.rb', line 13 def add_page(page) remove_page(page) @pages << page end |
#create_css ⇒ Object
23 24 25 26 27 |
# File 'lib/kinbote/value.rb', line 23 def create_css FileUtils.mkdir_p(file_name(:css, true)) if !File.exist?(file_name(:css, true)) File.open(file_name(:css), "w") if !File.exist?(file_name(:css)) @global_value.css! end |
#css! ⇒ Object
41 |
# File 'lib/kinbote/value.rb', line 41 def css!; @global_value == self ? @css = true : @global_value.css!; end |
#css? ⇒ Boolean
42 |
# File 'lib/kinbote/value.rb', line 42 def css?; @global_value == self ? @css : @global_value.css?; end |
#css_files ⇒ Object
35 36 37 |
# File 'lib/kinbote/value.rb', line 35 def css_files @global_value.css? ? ["/css/attributes/#{@attribute}/#{@value}"] : [] end |
#file_name(type, dir = nil) ⇒ Object
29 30 31 32 33 |
# File 'lib/kinbote/value.rb', line 29 def file_name(type, dir = nil) if type == :css return "#{$site.kinbote_path}/views/sass/attributes/#{@attribute}/#{!dir ? "#{@value}.sass" : ""}" end end |
#pages ⇒ Object
39 |
# File 'lib/kinbote/value.rb', line 39 def pages; @global_value == self ? @pages : @global_value.pages; end |
#remove_page(page) ⇒ Object
18 19 20 21 |
# File 'lib/kinbote/value.rb', line 18 def remove_page(page) @global_value.pages.delete_if{|p| p.slug == page.slug} @pages.delete_if{|p| p.slug == page.slug} end |
#to_s ⇒ Object
40 |
# File 'lib/kinbote/value.rb', line 40 def to_s; @value; end |