Class: OmniCat::Doc

Inherits:
Base
  • Object
show all
Defined in:
lib/omnicat/doc.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#to_hash

Constructor Details

#initialize(doc_hash = {}) ⇒ Doc

Returns a new instance of Doc.



8
9
10
11
12
# File 'lib/omnicat/doc.rb', line 8

def initialize(doc_hash = {})
  @content = doc_hash[:content]
  @count = (doc_hash[:count] || 1).to_i
  @tokens = tokenize_with_counts unless @tokens.is_a?(Hash)
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



6
7
8
# File 'lib/omnicat/doc.rb', line 6

def content
  @content
end

#countObject (readonly)

Returns the value of attribute count.



6
7
8
# File 'lib/omnicat/doc.rb', line 6

def count
  @count
end

#tokensObject (readonly)

Returns the value of attribute tokens.



6
7
8
# File 'lib/omnicat/doc.rb', line 6

def tokens
  @tokens
end

Instance Method Details

#decrement_countObject



18
19
20
# File 'lib/omnicat/doc.rb', line 18

def decrement_count
  @count -= 1 if @count > 0
end

#increment_countObject



14
15
16
# File 'lib/omnicat/doc.rb', line 14

def increment_count
  @count += 1
end