Class: SiSU_Wikispeak::Source::SplitTextObject

Inherits:
SiSU_Wikispeak::Source show all
Includes:
Format
Defined in:
lib/sisu/wikispeak.rb

Constant Summary collapse

@@alt_id_count =
0
@@dp =
nil

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from SiSU_Wikispeak::Source

#read

Constructor Details

#initialize(para) ⇒ SplitTextObject

Returns a new instance of SplitTextObject.



113
114
115
116
117
# File 'lib/sisu/wikispeak.rb', line 113

def initialize(para)
  @para=para
  @format,@ocn='ordinary','ordinary'
  @dp=@@dp ||=SiSU_Env::InfoEnv.new.digest.pattern
end

Instance Attribute Details

#formatObject (readonly)

Returns the value of attribute format.



112
113
114
# File 'lib/sisu/wikispeak.rb', line 112

def format
  @format
end

#levObject (readonly)

Returns the value of attribute lev.



112
113
114
# File 'lib/sisu/wikispeak.rb', line 112

def lev
  @lev
end

#lev_para_ocnObject (readonly)

Returns the value of attribute lev_para_ocn.



112
113
114
# File 'lib/sisu/wikispeak.rb', line 112

def lev_para_ocn
  @lev_para_ocn
end

#ocnObject (readonly)

Returns the value of attribute ocn.



112
113
114
# File 'lib/sisu/wikispeak.rb', line 112

def ocn
  @ocn
end

#textObject (readonly)

Returns the value of attribute text.



112
113
114
# File 'lib/sisu/wikispeak.rb', line 112

def text
  @text
end

Instance Method Details

#lev_segname_para_ocnObject



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/sisu/wikispeak.rb', line 118

def lev_segname_para_ocn
  @text=nil
  if @para =~/^(\d~|<:.+?>).+?#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/
    if /^(([1-6])~(\S+))\s+(\S.+?)#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/m.match(@para)
      @format,@lev,segname,@text,@ocn=$1,$2,$3,$4,$5
    elsif  /^(([1-6])~)\s+(\S.+?)#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/m.match(@para)
      @format,@lev,@text,@ocn=$1,$2,$3,$4
    elsif /<:(.+?)>\s*(\S.+?)#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/m.match(@para)
      @format,@text,@ocn=$1,$2,$3
    elsif /^(([1-6])~(\S+))\s+(\S.+?)#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;[um]\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/m.match(@para)
      @@alt_id_count+=1
      @format,@lev,segname,@text,@ocn=$1,$2,$3,$4,"x#{@@alt_id_count}"
    elsif  /^(([1-6])~)\s+(\S.+?)#{Mx[:id_o]}~(\d+);[um]\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/m.match(@para)
      @@alt_id_count+=1
      @format,@lev,@text,@ocn=$1,$2,$3,"x#{@@alt_id_count}"
    end
  else
    if /(.+?)#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/m.match(@para)
      @text,@ocn=$1,$2
    end
    if @para !~/#{Mx[:id_o]}~(\d+);(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$|^$/ #added 2002w06
      @text=/(.+?)/m.match(@para)[1]
    end
    if /^((\d)~(?:~\S+)?)\s+(.+)/m.match(@para)
      @format,@lev,@text=$1,$2,$3
    end
  end
  format=@format.dup
  @lev_para_ocn=if @para =~/.+#{Mx[:id_o]}~\d+;(?:\w|[0-6]:)\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}$/
    Format::FormatTextObject.new(format,@text,@ocn)
  else
    Format::FormatTextObject.new(format,@text,"#{Mx[:id_o]}~(\d+);[um]\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#{@dp}:#{@dp}#{Mx[:id_c]}")
  end
  self
end