Class: Clogs::Paragraph::TextStyle

Inherits:
Struct
  • Object
show all
Defined in:
lib/clogs/paragraph.rb

Overview

An immutable text style. Runs with equal styles can be drawn together.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bgObject

Returns the value of attribute bg

Returns:

  • (Object)

    the current value of bg



67
68
69
# File 'lib/clogs/paragraph.rb', line 67

def bg
  @bg
end

#boldObject

Returns the value of attribute bold

Returns:

  • (Object)

    the current value of bold



67
68
69
# File 'lib/clogs/paragraph.rb', line 67

def bold
  @bold
end

#colorObject

Returns the value of attribute color

Returns:

  • (Object)

    the current value of color



67
68
69
# File 'lib/clogs/paragraph.rb', line 67

def color
  @color
end

#familyObject

Returns the value of attribute family

Returns:

  • (Object)

    the current value of family



67
68
69
# File 'lib/clogs/paragraph.rb', line 67

def family
  @family
end

#italicObject

Returns the value of attribute italic

Returns:

  • (Object)

    the current value of italic



67
68
69
# File 'lib/clogs/paragraph.rb', line 67

def italic
  @italic
end

#ownerObject

Returns the value of attribute owner

Returns:

  • (Object)

    the current value of owner



67
68
69
# File 'lib/clogs/paragraph.rb', line 67

def owner
  @owner
end

#sizeObject

Returns the value of attribute size

Returns:

  • (Object)

    the current value of size



67
68
69
# File 'lib/clogs/paragraph.rb', line 67

def size
  @size
end

#underlineObject

Returns the value of attribute underline

Returns:

  • (Object)

    the current value of underline



67
68
69
# File 'lib/clogs/paragraph.rb', line 67

def underline
  @underline
end

Instance Method Details

#cache_keyObject



68
69
70
# File 'lib/clogs/paragraph.rb', line 68

def cache_key
  @cache_key ||= [family, size, bold, italic].freeze
end

#same_run_as?(other) ⇒ Boolean

Returns:

  • (Boolean)


76
77
78
79
# File 'lib/clogs/paragraph.rb', line 76

def same_run_as?(other)
  family == other.family && size == other.size && bold == other.bold &&
    italic == other.italic && underline == other.underline && color == other.color
end

#with(**changes) ⇒ Object



72
73
74
# File 'lib/clogs/paragraph.rb', line 72

def with(**changes)
  TextStyle.new(to_h.merge(changes))
end