class DYI::Font

@since 0.0.0

Constants

DEFAULT_SIZE
IMPLEMENT_ATTRIBUTES
VALID_VALUES

Public Class Methods

new(options={}) click to toggle source
# File lib/dyi/font.rb, line 50
def initialize(options={})
  case options
  when Font
    IMPLEMENT_ATTRIBUTES.each do |attr|
      instance_variable_set("@#{attr}", options.__send__(attr))
    end
  when Hash
    options.each do |attr, value|
      __send__(attr.to_s + '=', value) if IMPLEMENT_ATTRIBUTES.include?(attr.to_sym)
    end
  else
    raise TypeError, "#{options.class} can't be coerced into #{self.class}"
  end
end
new(*args) click to toggle source
Calls superclass method
# File lib/dyi/font.rb, line 123
def new(*args)
  return args.first if args.size == 1 && args.first.instance_of?(self)
  super
end
new_or_nil(*args) click to toggle source
# File lib/dyi/font.rb, line 128
def new_or_nil(*args)
  (args.size == 1 && args.first.nil?) ? nil : new(*args)
end
to_cls_font(font) click to toggle source
# File lib/ironruby.rb, line 123
def to_cls_font(font)
  font ? font.to_cls_font : System::Drawing::Font.new('', DEFAULT_SIZE.to_f('pt'))
end

Public Instance Methods

attributes() click to toggle source
# File lib/dyi/font.rb, line 107
def attributes
  IMPLEMENT_ATTRIBUTES.inject({}) do |hash, attr|
    value = instance_variable_get("@#{attr}")
    hash[/^font_/ =~ attr.to_s ? attr : "font_#{attr}".to_sym] = value.to_s unless value.nil?
    hash
  end
end
draw_size() click to toggle source
# File lib/dyi/font.rb, line 103
def draw_size
  @size || DEFAULT_SIZE
end
empty?() click to toggle source
# File lib/dyi/font.rb, line 115
def empty?
  IMPLEMENT_ATTRIBUTES.all? do |attr|
    not instance_variable_get("@#{attr}")
  end
end
font_family() click to toggle source
# File lib/dyi/font.rb, line 36
    
font_family=(value) click to toggle source
# File lib/dyi/font.rb, line 91
def font_family=(value)
  @font_family = value.to_s.size != 0 ? value.to_s : nil
end
size() click to toggle source
# File lib/dyi/font.rb, line 45
    
size=(value) click to toggle source
# File lib/dyi/font.rb, line 95
def size=(value)
  @size = Length.new_or_nil(value)
end
size_adjust=(value) click to toggle source
# File lib/dyi/font.rb, line 99
def size_adjust=(value)
  @size_adjust = value ? value.to_f : nil
end
style() click to toggle source
# File lib/dyi/font.rb, line 39
    
style= (value) click to toggle source
# File lib/dyi/font.rb, line 66
    
to_cls_font() click to toggle source
# File lib/ironruby.rb, line 118
def to_cls_font
  System::Drawing::Font.new(font_family || '', size ? size.to_f : DEFAULT_SIZE.to_f('pt'))
end
weight() click to toggle source
# File lib/dyi/font.rb, line 42
    
weight= (value) click to toggle source
# File lib/dyi/font.rb, line 73