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.



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/tk/font.rb', line 148

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



189
190
191
# File 'lib/tk/font.rb', line 189

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

Instance Method Details

#[](slot) ⇒ Object



181
182
183
# File 'lib/tk/font.rb', line 181

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

#[]=(slot, value) ⇒ Object



184
185
186
187
# File 'lib/tk/font.rb', line 184

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

#cloneObject



167
168
169
# File 'lib/tk/font.rb', line 167

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

#dupObject



164
165
166
# File 'lib/tk/font.rb', line 164

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

#fontObject Also known as: font_id, name, to_s



174
175
176
# File 'lib/tk/font.rb', line 174

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

#to_evalObject



171
172
173
# File 'lib/tk/font.rb', line 171

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