Class: Object

Inherits:
BasicObject
Defined in:
lib/muflax/blank.rb,
lib/muflax/align.rb,
lib/muflax/objects.rb,
lib/muflax/deep_dup.rb,
lib/muflax/deep_dup.rb,
lib/muflax/enumerable.rb

Overview

Copyright Steffie Dorn <[email protected]>, 2017 License: GNU APGLv3 (or later) <www.gnu.org/copyleft/gpl.html>

Instance Method Summary collapse

Instance Method Details

#blank?Boolean

Returns:

  • (Boolean)


7
# File 'lib/muflax/blank.rb', line 7

def blank?      	; !self                   	; end

#deep_dupObject



7
8
9
# File 'lib/muflax/deep_dup.rb', line 7

def deep_dup
  duplicable? ? dup : self
end

#differences_with(other) ⇒ Object



41
42
43
44
45
46
47
48
49
# File 'lib/muflax/objects.rb', line 41

def differences_with(other)
  # get list of all attributes
  attrs = (self.class.attr_readers + self.class.attr_writers).uniq.sort

  # pick all attributes that they disagree about
  attrs.reject do |attr|
    self.respond_to? attr and other.respond_to? attr and self.send(attr) == other.send(attr)
  end
end

#duplicable?Boolean

Returns:

  • (Boolean)


35
# File 'lib/muflax/deep_dup.rb', line 35

def duplicable?	; true 	; end

#in?(other) ⇒ Boolean

Returns:

  • (Boolean)


70
71
72
73
74
# File 'lib/muflax/enumerable.rb', line 70

def in? other
  other.include?(self)
rescue NoMethodError
  raise ArgumentError.new("The parameter passed to #in? must respond to #include?")
end

#nil_if_blankObject



9
# File 'lib/muflax/blank.rb', line 9

def nil_if_blank	; self.blank? ? nil : self	; end

#present?Boolean

Returns:

  • (Boolean)


8
# File 'lib/muflax/blank.rb', line 8

def present?    	; !blank?                 	; end

#str_lengthObject

consistent string length



28
29
30
31
32
33
34
35
36
# File 'lib/muflax/align.rb', line 28

def str_length
  s  	= self.to_s
  ss 	= StringScanner.new(s)
  len	= s.length

  len -= ss.matched_size while ss.skip_until(String::ANSIColorRegexp)

  len
end