Class: Fontist::StyleVersion

Inherits:
Object
  • Object
show all
Defined in:
lib/fontist/style_version.rb

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ StyleVersion

Returns a new instance of StyleVersion.



3
4
5
# File 'lib/fontist/style_version.rb', line 3

def initialize(text)
  @text = text
end

Instance Method Details

#<=>(other) ⇒ Object



27
28
29
# File 'lib/fontist/style_version.rb', line 27

def <=>(other)
  value <=> other.value
end

#==(other) ⇒ Object



31
32
33
# File 'lib/fontist/style_version.rb', line 31

def ==(other)
  value == other.value
end

#default_valueObject



23
24
25
# File 'lib/fontist/style_version.rb', line 23

def default_value
  ["0"]
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/fontist/style_version.rb', line 35

def eql?(other)
  value.eql?(other.value)
end

#hashObject



39
40
41
# File 'lib/fontist/style_version.rb', line 39

def hash
  value.hash
end

#numbersObject



15
16
17
# File 'lib/fontist/style_version.rb', line 15

def numbers
  string_version&.split(".")&.map(&:strip)
end

#string_versionObject



19
20
21
# File 'lib/fontist/style_version.rb', line 19

def string_version
  @text&.split(";")&.first
end

#to_sObject



7
8
9
# File 'lib/fontist/style_version.rb', line 7

def to_s
  value.join(" . ")
end

#valueObject



11
12
13
# File 'lib/fontist/style_version.rb', line 11

def value
  @value ||= numbers || default_value
end