Class: TkFont::DescendantFont

Inherits:
Object
  • Object
show all
Defined in:
lib/tk/font.rb

Instance Method Summary collapse

Constructor Details

#initialize(compound, type) ⇒ DescendantFont

Returns a new instance of DescendantFont.



120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/tk/font.rb', line 120

def initialize(compound, type)
  unless compound.kind_of?(TkFont)
    fail ArgumentError, "a TkFont object is expected for the 1st argument"
  end
  @compound = compound
  case type
  when 'kanji', 'latin', 'ascii'
    @type = type
  when :kanji, :latin, :ascii
    @type = type.to_s
  else
    fail ArgumentError, "unknown type '#{type}'"
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(id, *args) ⇒ Object



157
158
159
# File 'lib/tk/font.rb', line 157

def method_missing(id, *args)
  @compound.__send__(@type + '_' + id.id2name, *args)
end

Instance Method Details

#[](slot) ⇒ Object



149
150
151
# File 'lib/tk/font.rb', line 149

def [](slot)
  @compound.__send__(@type + '_configinfo', slot)
end

#[]=(slot, value) ⇒ Object



152
153
154
155
# File 'lib/tk/font.rb', line 152

def []=(slot, value)
  @compound.__send__(@type + '_configure', slot, value)
  value
end

#cloneObject



138
139
140
# File 'lib/tk/font.rb', line 138

def clone
  fail RuntimeError, "cannot clone a descendant font"
end

#dupObject



135
136
137
# File 'lib/tk/font.rb', line 135

def dup
  fail RuntimeError, "cannot dupulicate a descendant font"
end

#fontObject



145
146
147
# File 'lib/tk/font.rb', line 145

def font
  @compound.__send__(@type + '_font_id')
end

#to_evalObject



142
143
144
# File 'lib/tk/font.rb', line 142

def to_eval
  @compound.__send__(@type + '_font_id')
end