Class: PnoteClient::Documents::Hml::Char

Inherits:
Object
  • Object
show all
Defined in:
lib/pnote_client/documents/hml/char.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text = '') ⇒ Char

Returns a new instance of Char.



25
26
27
# File 'lib/pnote_client/documents/hml/char.rb', line 25

def initialize(text = '')
  @text = text
end

Instance Attribute Details

#textObject (readonly)

Returns the value of attribute text.



23
24
25
# File 'lib/pnote_client/documents/hml/char.rb', line 23

def text
  @text
end

Class Method Details

.from_tag(char_tag) ⇒ Object

Textable Element



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/pnote_client/documents/hml/char.rb', line 7

def self.from_tag(char_tag)
  char = self.new

  char_tag.children.each do |child|
    if child.name == 'LINEBREAK'
      char.add_text("\n")
    elsif child.name == 'TAB'
      char.add_text("\t")
    else
      char.add_text(child.content)
    end
  end

  return char
end

Instance Method Details

#add_text(text) ⇒ Object



29
30
31
# File 'lib/pnote_client/documents/hml/char.rb', line 29

def add_text(text)
  @text += text
end

#contentObject



33
34
35
36
37
# File 'lib/pnote_client/documents/hml/char.rb', line 33

def content
  # 일반 텍스트는 변환작업을 하지 않지만
  # 닮음기호는 예외 상황으로 처리
  @text.gsub(/\xf3\xb0\x81\x80/, "$\\backsim$")
end

#textable?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/pnote_client/documents/hml/char.rb', line 39

def textable?
  return true
end