Class: Kinbote::Value
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#pages ⇒ Object
readonly
Returns the value of attribute pages.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #add_page(page) ⇒ Object
- #has_page?(slug) ⇒ Boolean
-
#initialize(value, page, attribute) ⇒ Value
constructor
A new instance of Value.
- #rem_page(page) ⇒ Object
- #to_s ⇒ Object
Methods included from Kinfile
#create_file, #create_files, #delete_file, #delete_files, #file_size, #files, #has_file?, #init_files, #reset_file_size
Constructor Details
#initialize(value, page, attribute) ⇒ Value
Returns a new instance of Value.
6 7 8 9 10 |
# File 'lib/kinbote/value.rb', line 6 def initialize(value, page, attribute) @value = value.to_s @attribute = attribute @pages = [page] end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
4 5 6 |
# File 'lib/kinbote/value.rb', line 4 def attribute @attribute end |
#pages ⇒ Object (readonly)
Returns the value of attribute pages.
4 5 6 |
# File 'lib/kinbote/value.rb', line 4 def pages @pages end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
4 5 6 |
# File 'lib/kinbote/value.rb', line 4 def value @value end |
Instance Method Details
#add_page(page) ⇒ Object
12 13 14 15 |
# File 'lib/kinbote/value.rb', line 12 def add_page(page) rem_page(page) @pages << page end |
#has_page?(slug) ⇒ Boolean
21 22 23 |
# File 'lib/kinbote/value.rb', line 21 def has_page?(slug) @pages.map{|p| p.slug}.include?(slug) end |
#rem_page(page) ⇒ Object
17 18 19 |
# File 'lib/kinbote/value.rb', line 17 def rem_page(page) @pages.delete_if{|p| p.slug == page.slug} end |
#to_s ⇒ Object
25 |
# File 'lib/kinbote/value.rb', line 25 def to_s; @value; end |