Class: Wikiwhat::Results

Inherits:
Object
  • Object
show all
Defined in:
lib/wikiwhat/parse.rb

Direct Known Subclasses

Media, Text

Instance Method Summary collapse

Constructor Details

#initializeResults

Returns a new instance of Results.



6
7
8
# File 'lib/wikiwhat/parse.rb', line 6

def initialize
  @result = nil
end

Instance Method Details

#content_split(start, finish = nil) ⇒ Object

Splits the content into side bar and everything else. This method is for Parsing methods that use the raw markup from the revisions call. Specify start as 0 for sidebar content, for everything else specify ‘content_split(1, -1)’

TODO:split the content from the catagory info



33
34
35
36
37
38
39
40
# File 'lib/wikiwhat/parse.rb', line 33

def content_split(start, finish=nil)
  @content = @request.split("'''")
  if finish == nil
    @content[start]
  else
    @content[start..finish].join
  end
end

#pull_from_hash(hash, key) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/wikiwhat/parse.rb', line 10

def pull_from_hash(hash, key)
  @hash = hash
  @key = key

  if @hash.include?(@key)
    @result = @hash[@key]
  else
    @hash.each_pair do |k, v|
      if v.class == Hash
        pull_from_hash(v, @key)
      end
    end
  end
  @result
end