Sha256: c43c93b2c50b36173005a790c0029fd964ba07c7bf20168524a612326453e627

Contents?: true

Size: 1.25 KB

Versions: 2

Compression:

Stored size: 1.25 KB

Contents

module RubyXL
  module FontConvenienceMethods
    # Funny enough, but presence of <i> without value (equivalent to `val == nul`) means "italic = true"!
    # Same is true for bold, strikethrough, etc
    def is_italic
      i && (i.val != false)
    end

    def is_bold
      b && (b.val != false)
    end

    def is_underlined
      u && (u.val != false)
    end

    def is_strikethrough
      strike && (strike.val != false)
    end

    def get_name
      name && name.val
    end

    def get_size
      sz && sz.val
    end

    def get_rgb_color
      color && color.rgb
    end

    def set_italic(val)
      self.i = RubyXL::BooleanValue.new(:val => val)
    end

    def set_bold(val)
      self.b = RubyXL::BooleanValue.new(:val => val)
    end

    def set_underline(val)
      self.u = RubyXL::BooleanValue.new(:val => val)
    end

    def set_strikethrough(val)
      self.strike = RubyXL::BooleanValue.new(:val => val)
    end

    def set_name(val)
      self.name = RubyXL::StringValue.new(:val => val)
    end

    def set_size(val)
      self.sz = RubyXL::FloatValue.new(:val => val)
    end

    def set_rgb_color(font_color)
      self.color = RubyXL::Color.new(:rgb => font_color.to_s)
    end
  end

  RubyXL::Font.include(RubyXL::FontConvenienceMethods)
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubyXL-3.4.1 lib/rubyXL/convenience_methods/font.rb
rubyXL-3.4.0 lib/rubyXL/convenience_methods/font.rb