Class: Kwartz::TextConverter

Inherits:
Converter show all
Defined in:
lib/kwartz/converter.rb

Overview

convert presentation data (html) into a list of Statement. notice that TextConverter class hanlde html file as text format, not html format.

Instance Attribute Summary collapse

Attributes inherited from Converter

#handler

Instance Method Summary collapse

Methods inherited from Converter

get_class, register_class

Methods included from ConvertErrorHelper

#convert_error

Constructor Details

#initialize(handler, properties = {}) ⇒ TextConverter

Returns a new instance of TextConverter.



984
985
986
987
# File 'lib/kwartz/converter.rb', line 984

def initialize(handler, properties={})
  super
  @dattr = properties.fetch(:dattr, Config::PROPERTY_DATTR)    # default: 'kw:d'
end

Instance Attribute Details

#linenumObject (readonly)

Returns the value of attribute linenum.



1002
1003
1004
# File 'lib/kwartz/converter.rb', line 1002

def linenum
  @linenum
end

#restObject (readonly)

Returns the value of attribute rest.



1002
1003
1004
# File 'lib/kwartz/converter.rb', line 1002

def rest
  @rest
end

Instance Method Details

#convert(input, filename = '') ⇒ Object



1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
# File 'lib/kwartz/converter.rb', line 1005

def convert(input, filename='')
  reset(input, filename)
  stmt_list = []
  _convert(stmt_list)
  ruleset = @handler.get_ruleset('#DOCUMENT')
  if ruleset
    stmt_list2 = []
    elem_info = nil
    r = ruleset
    @handler.expand_statements(r.before, stmt_list2, elem_info) if r.before
    if r.logic
      @handler.expand_statements(r.logic, stmt_list2, elem_info)
    else
      stmt_list2.concat(stmt_list)
    end
    @handler.expand_statements(r.after,  stmt_list2, elem_info) if r.after
    stmt_list = stmt_list2
  end
  return stmt_list
end