Class: SsSyntax::Parses::HeartVoice

Inherits:
Object
  • Object
show all
Defined in:
lib/ss_syntax/parses/heart_voice.rb

Class Method Summary collapse

Class Method Details

.check(text) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/ss_syntax/parses/heart_voice.rb', line 4

def self.check(text)
  if text.match(/.+_/)
    return true
  end

  return false
end

.get(text, characters) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ss_syntax/parses/heart_voice.rb', line 12

def self.get(text, characters)
  key, body, gion = '', '', ''

  gion_match = text.match(/(.+)_ (.+) _ (.+)/) # with 擬音
  if gion_match != nil
    key, body, gion = gion_match[1], gion_match[2], gion_match[3]
  else
    match = text.match(/(.+)_ (.+)/)
    key, body = match[1], match[2]
  end

  return "#{characters[key]}#{body}#{gion}" if characters[key] != nil
  return "#{key}#{body}#{gion}"
end