Class: Sjp::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/sjp/parser.rb

Overview

Parser class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeParser

Returns a new instance of Parser.



11
12
13
# File 'lib/sjp/parser.rb', line 11

def initialize
  @word, @html, @page, @hash = '', '', nil, {}
end

Instance Attribute Details

#htmlObject

Returns the value of attribute html.



9
10
11
# File 'lib/sjp/parser.rb', line 9

def html
  @html
end

#pageObject (readonly)

Returns the value of attribute page.



9
10
11
# File 'lib/sjp/parser.rb', line 9

def page
  @page
end

#wordObject

Returns the value of attribute word.



9
10
11
# File 'lib/sjp/parser.rb', line 9

def word
  @word
end

Instance Method Details

#allowed?Boolean

Returns:

  • (Boolean)


29
30
31
32
33
# File 'lib/sjp/parser.rb', line 29

def allowed?
  # TODO: tests for exist and allow
  # exist? && (status != 'niedopuszczalne w grach')
  status == 'dopuszczalne w grach '
end

#descriptionObject



39
40
41
# File 'lib/sjp/parser.rb', line 39

def description
  @page.css('p')[3].text
end

#exist?Boolean

Returns:

  • (Boolean)


22
23
24
25
26
27
# File 'lib/sjp/parser.rb', line 22

def exist?
  ![
    'słowo występuje tylko jako część innych haseł',
    'nie występuje w słowniku'
  ].include? status
end

#variety?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/sjp/parser.rb', line 35

def variety?
  @hash['odmienność:'] == 'tak'
end