Class: ConTeXtSetup::Keywords

Inherits:
Param show all
Defined in:
lib/tex/context/contextsetup.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Param

#opt, #optional?, #sanitize_html, #show

Methods inherited from SetupXML

parse_xml, tag_method

Constructor Details

#initialize(interface) ⇒ Keywords

parse_xml



677
678
679
680
681
682
683
# File 'lib/tex/context/contextsetup.rb', line 677

def initialize(interface)
  @interface=interface
  @optional=false
  @list=false
  @default=nil
  @keywords=[]
end

Instance Attribute Details

#defaultObject

Returns the value of attribute default.



665
666
667
# File 'lib/tex/context/contextsetup.rb', line 665

def default
  @default
end

#keywordsObject

Returns the value of attribute keywords.



665
666
667
# File 'lib/tex/context/contextsetup.rb', line 665

def keywords
  @keywords
end

#listObject

Returns the value of attribute list.



665
666
667
# File 'lib/tex/context/contextsetup.rb', line 665

def list
  @list
end

#optionalObject

Returns the value of attribute optional.



665
666
667
# File 'lib/tex/context/contextsetup.rb', line 665

def optional
  @optional
end

Instance Method Details

#==(other) ⇒ Object

Return true if the two objects are the same. Comparison is based on the attributes ‘list’, ‘default’, ‘optional’ and ‘keywords’.



699
700
701
702
703
# File 'lib/tex/context/contextsetup.rb', line 699

def ==(other)
  return false unless Keywords===other
  other.optional == @optional && other.keywords == @keywords && 
    other.default == @default && other.list == @list
end

#parse_xml(keywords) ⇒ Object



666
667
668
669
670
671
672
673
674
675
# File 'lib/tex/context/contextsetup.rb', line 666

def parse_xml(keywords)
  @optional = keywords.attributes['optional']=="yes"
  @list     = keywords.attributes['list']=="yes"
  keywords.each_element do |keyword|
    @keywords << keyword.attributes["type"]
    if keyword.attributes["default"]=="yes"
      @default=@keywords.size - 1
    end
  end
end

#to_html(detail = true, cls = "first") ⇒ Object



684
685
686
687
688
689
690
691
692
693
694
695
696
# File 'lib/tex/context/contextsetup.rb', line 684

def to_html(detail=true,cls="first")
  head=@list ? "[...,...,...]" : "[...]"
  if detail
    # create list
    lst=[]
    @keywords.each_with_index { |kw, i|
      lst << (@default==i ? strong { kw } : kw )
    }  
    tr { td(:class => cls) { head } + td(:class => cls) { sanitize_html(lst.join(" ")) } }
  else
    head
  end
end