Sha256: a9c526da24ffdbabd7d6d2d9f37f481d48b2b38457bfec76d16c2d5260a39cec

Contents?: true

Size: 1.28 KB

Versions: 29

Compression:

Stored size: 1.28 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.send(:include, RubyXL::FontConvenienceMethods) # ruby 2.1 compat
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
rubyXL-3.4.33 lib/rubyXL/convenience_methods/font.rb
rubyXL-3.4.32 lib/rubyXL/convenience_methods/font.rb
rubyXL-3.4.31 lib/rubyXL/convenience_methods/font.rb
rubyXL-3.4.30 lib/rubyXL/convenience_methods/font.rb
rubyXL-3.4.29 lib/rubyXL/convenience_methods/font.rb
rubyXL-3.4.28 lib/rubyXL/convenience_methods/font.rb
rubyXL-3.4.27 lib/rubyXL/convenience_methods/font.rb
rubyXL-3.4.26 lib/rubyXL/convenience_methods/font.rb
rubyXL-3.4.25 lib/rubyXL/convenience_methods/font.rb
rubyXL-3.4.24 lib/rubyXL/convenience_methods/font.rb
rubyXL-3.4.23 lib/rubyXL/convenience_methods/font.rb
rubyXL-3.4.22 lib/rubyXL/convenience_methods/font.rb
rubyXL-3.4.21 lib/rubyXL/convenience_methods/font.rb
rubyXL-3.4.20 lib/rubyXL/convenience_methods/font.rb
rubyXL-3.4.18 lib/rubyXL/convenience_methods/font.rb
rubyXL-3.4.17 lib/rubyXL/convenience_methods/font.rb
rubyXL-3.4.16 lib/rubyXL/convenience_methods/font.rb
rubyXL-3.4.15 lib/rubyXL/convenience_methods/font.rb
rubyXL-3.4.14 lib/rubyXL/convenience_methods/font.rb
rubyXL-3.4.12 lib/rubyXL/convenience_methods/font.rb