Class: Srx::Data

Inherits:
XmlWrapper
  • Object
show all
Defined in:
lib/srx/data.rb

Overview

SRX data

Defined Under Namespace

Classes: LanguageMap, LanguageRule

Constant Summary

Constants inherited from XmlWrapper

XmlWrapper::NS

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.defaultData

Default SRX rules

Returns:



28
29
30
# File 'lib/srx/data.rb', line 28

def default
  from_file(path: File.expand_path('srx-20-sample.srx', __dir__))
end

.from_file(path:) ⇒ Data

Parameters:

  • path (String)

Returns:



34
35
36
# File 'lib/srx/data.rb', line 34

def from_file(path:)
  File.open(path, &method(:from_io))
end

.from_io(io) ⇒ Data

Parameters:

  • io (IO)

Returns:



40
41
42
# File 'lib/srx/data.rb', line 40

def from_io(io)
  new(Nokogiri::XML.parse(io))
end

Instance Method Details

#cascade?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/srx/data.rb', line 49

def cascade?
  @cascade ||= header['cascade'] == 'yes'
end

#include_end_formatting?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/srx/data.rb', line 57

def include_end_formatting?
  @include_end_formatting ||= include_formatting?(:end)
end

#include_isolated_formatting?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/srx/data.rb', line 61

def include_isolated_formatting?
  @include_isolated_formatting ||= include_formatting?(:isolated)
end

#include_start_formatting?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/srx/data.rb', line 53

def include_start_formatting?
  @include_start_formatting ||= include_formatting?(:start)
end

#language_rulesArray<LanguageRule>

Returns:



66
67
68
69
70
# File 'lib/srx/data.rb', line 66

def language_rules
  @language_rules ||=
    xpath(:srx, :body, :languagerules, :languagerule)
    .map { |langrule| LanguageRule.new(langrule) }
end

#map_rulesArray<LanguageMap>

Returns:



73
74
75
76
77
# File 'lib/srx/data.rb', line 73

def map_rules
  @map_rules ||=
    xpath(:srx, :body, :maprules, :languagemap)
    .map { |maprule| LanguageMap.new(maprule) }
end

#segment_subflows?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/srx/data.rb', line 45

def segment_subflows?
  @segment_subflows ||= header['segmentsubflows'] == 'yes'
end