Class: Just

Inherits:
Object
  • Object
show all
Defined in:
lib/just_maybe/just.rb

Instance Method Summary collapse

Constructor Details

#initialize(object) ⇒ Just

Returns a new instance of Just.



2
3
4
# File 'lib/just_maybe/just.rb', line 2

def initialize(object)
  @object = object
end

Instance Method Details

#nothing?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/just_maybe/just.rb', line 6

def nothing?
  false
end

#something?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/just_maybe/just.rb', line 10

def something?
  true
end

#to_sObject



18
19
20
# File 'lib/just_maybe/just.rb', line 18

def to_s
  "Just: #{@object}"
end

#try {|@object| ... } ⇒ Object

Yields:

  • (@object)


14
15
16
# File 'lib/just_maybe/just.rb', line 14

def try
  yield @object if block_given?
end