Class: Kinbote::Value

Inherits:
Object
  • Object
show all
Includes:
Kinfile
Defined in:
lib/kinbote/value.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#attributeObject (readonly)

Returns the value of attribute attribute.



4
5
6
# File 'lib/kinbote/value.rb', line 4

def attribute
  @attribute
end

#pagesObject (readonly)

Returns the value of attribute pages.



4
5
6
# File 'lib/kinbote/value.rb', line 4

def pages
  @pages
end

#valueObject (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

Returns:

  • (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_sObject



25
# File 'lib/kinbote/value.rb', line 25

def to_s; @value; end