Class: Sovren::Language

Inherits:
Object
  • Object
show all
Defined in:
lib/sovren/language.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#language_codeObject

Returns the value of attribute language_code.



3
4
5
# File 'lib/sovren/language.rb', line 3

def language_code
  @language_code
end

#readObject

Returns the value of attribute read.



3
4
5
# File 'lib/sovren/language.rb', line 3

def read
  @read
end

#speakObject

Returns the value of attribute speak.



3
4
5
# File 'lib/sovren/language.rb', line 3

def speak
  @speak
end

#writeObject

Returns the value of attribute write.



3
4
5
# File 'lib/sovren/language.rb', line 3

def write
  @write
end

Class Method Details

.parse(languages) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/sovren/language.rb', line 5

def self.parse(languages)
  return Array.new if languages.nil?
  result = languages.css('Language').collect do |item|
    c = Language.new
    c.language_code = item.css('LanguageCode').text
    c.read = item.css('Read').text == "true" rescue nil
    c.write = item.css('Write').text == "true" rescue nil
    c.speak = item.css('Speak').text == "true" rescue nil
    c
  end
  result
end

Instance Method Details

#read?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/sovren/language.rb', line 18

def read?
  !read.nil? && read
end

#speak?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/sovren/language.rb', line 26

def speak?
  !speak.nil? && speak
end

#write?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/sovren/language.rb', line 22

def write?
  !write.nil? && write
end