Class: Ciyuan::Character

Inherits:
Object
  • Object
show all
Defined in:
lib/ciyuan/character.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(doc, get_images = false) ⇒ Character

Returns a new instance of Character.



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/ciyuan/character.rb', line 6

def initialize(doc, get_images=false)
  @etymology = doc.search("#charEty").first.content
  @phonetic = doc.search("#charPhon").first.content
  @simplification = doc.search("#SimplificationMech").first.content
  @english_explanation = doc.search("#EnglishExplanation").first.content
  @unicode = doc.search("#SimplifiedUCS2Hex").first.content
  if get_images
    @seal_images = doc.search("#SealImages img").map{|element| File.join(BASE_URL,element.attribute("src"))}
    @lst_images = doc.search("#LstImages img").map{|element| File.join(BASE_URL,element.attribute("src"))}
    @bronze_images = doc.search("#BronzeImages img").map{|element| File.join(BASE_URL,element.attribute("src"))}
    @oracle_images = doc.search("#OracleImages img").map{|element| File.join(BASE_URL,element.attribute("src"))}
  end
end

Instance Attribute Details

#bronze_imagesObject

Returns the value of attribute bronze_images.



3
4
5
# File 'lib/ciyuan/character.rb', line 3

def bronze_images
  @bronze_images
end

#english_explanationObject

Returns the value of attribute english_explanation.



3
4
5
# File 'lib/ciyuan/character.rb', line 3

def english_explanation
  @english_explanation
end

#etymologyObject

Returns the value of attribute etymology.



3
4
5
# File 'lib/ciyuan/character.rb', line 3

def etymology
  @etymology
end

#lst_imagesObject

Returns the value of attribute lst_images.



3
4
5
# File 'lib/ciyuan/character.rb', line 3

def lst_images
  @lst_images
end

#oracle_imagesObject

Returns the value of attribute oracle_images.



3
4
5
# File 'lib/ciyuan/character.rb', line 3

def oracle_images
  @oracle_images
end

#phoneticObject

Returns the value of attribute phonetic.



3
4
5
# File 'lib/ciyuan/character.rb', line 3

def phonetic
  @phonetic
end

#seal_imagesObject

Returns the value of attribute seal_images.



3
4
5
# File 'lib/ciyuan/character.rb', line 3

def seal_images
  @seal_images
end

#simplificationObject

Returns the value of attribute simplification.



3
4
5
# File 'lib/ciyuan/character.rb', line 3

def simplification
  @simplification
end