Class: ConTeXtSetup::Interface

Inherits:
SetupXML
  • Object
show all
Defined in:
lib/tex/context/contextsetup.rb

Overview

Main class for parsing the cont-??.xml file. Just feed the root element (cd:interface) or a command element (cd:document) into the class method parse_xml. These elements must be of type REXML::Element.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SetupXML

tag_method

Constructor Details

#initialize(dummy = nil) ⇒ Interface

Dummy parameter is only for a nicer piece of code in another place



117
118
119
120
121
122
# File 'lib/tex/context/contextsetup.rb', line 117

def initialize(dummy=nil)
  @language="en"
  @version=nil
  @commands={}
  @defines={}
end

Instance Attribute Details

#commandsObject

Hash of the commands. The key is the name of the command + start if it is an environment. The value is an array of the variants of the command.



89
90
91
# File 'lib/tex/context/contextsetup.rb', line 89

def commands
  @commands
end

#definesObject

The resolve parts



91
92
93
# File 'lib/tex/context/contextsetup.rb', line 91

def defines
  @defines
end

#languageObject

The language of the interface as a String. Default is “en”



82
83
84
# File 'lib/tex/context/contextsetup.rb', line 82

def language
  @language
end

#versionObject

The version number of the interface definition. Only set if is read from xml



85
86
87
# File 'lib/tex/context/contextsetup.rb', line 85

def version
  @version
end

Class Method Details

.parse_xml(elt) ⇒ Object



75
76
77
78
79
# File 'lib/tex/context/contextsetup.rb', line 75

def parse_xml(elt)
  t=new
  t.parse_xml(elt)
  return t
end

Instance Method Details

#==(other) ⇒ Object



124
125
126
# File 'lib/tex/context/contextsetup.rb', line 124

def ==(other)
  Interface===other && @commands == other.commands
end

#parse_xml(elt) ⇒ Object

:nodoc:



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/tex/context/contextsetup.rb', line 92

def parse_xml(elt)  # :nodoc: 
  case elt.name
  when "interface"
    # one or more <command ...> 
    @language = elt.attributes["language"]
    @version  = elt.attributes["version"]
    elt.each_element do |cmd_or_define|
      case cmd_or_define.name
      when "command"
        add_command(cmd_or_define)
      when "define"
        d=Define.parse_xml(cmd_or_define,self)
        @defines[d.name]=d
      else
        raise "not implemented: interface/#{cmd_or_define.name}"
      end
    end
  when "command"
    add_command(elt)
  else
    raise ArgumentError, "The top element for parse_xml should be 'interface' or 'command', but is '#{elt.name}'"
  end
end