Class: ApiDiff::Property

Inherits:
Object
  • Object
show all
Defined in:
lib/api_diff/property.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, type:, writable:, static:) ⇒ Property

Returns a new instance of Property.



12
13
14
15
16
17
# File 'lib/api_diff/property.rb', line 12

def initialize(name:, type:, writable:, static:)
  @name = name
  @type = type
  @writable = writable
  @static = static
end

Class Attribute Details

.readonly_keywordObject

Returns the value of attribute readonly_keyword.



7
8
9
# File 'lib/api_diff/property.rb', line 7

def readonly_keyword
  @readonly_keyword
end

.writable_keywordObject

Returns the value of attribute writable_keyword.



7
8
9
# File 'lib/api_diff/property.rb', line 7

def writable_keyword
  @writable_keyword
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/api_diff/property.rb', line 10

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



10
11
12
# File 'lib/api_diff/property.rb', line 10

def type
  @type
end

Instance Method Details

#<=>(other) ⇒ Object



43
44
45
46
47
48
49
50
# File 'lib/api_diff/property.rb', line 43

def <=>(other)
  # static at the bottom
  return 1 if is_static? and not other.is_static?
  return -1 if not is_static? and other.is_static?

  # sort by name
  name <=> other.name
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/api_diff/property.rb', line 31

def eql?(other)
  to_s == other.to_s
end

#hashObject



27
28
29
# File 'lib/api_diff/property.rb', line 27

def hash
  to_s.hash
end

#is_static?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/api_diff/property.rb', line 23

def is_static?
  @static
end

#is_writable?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/api_diff/property.rb', line 19

def is_writable?
  @writable
end

#to_sObject



35
36
37
38
39
40
41
# File 'lib/api_diff/property.rb', line 35

def to_s
  result = []
  result << "static" if is_static?
  result << (is_writable? ? self.class.writable_keyword : self.class.readonly_keyword)
  result << "#{name}: #{type}"
  result.join(" ")
end