Skip to content

Instantly share code, notes, and snippets.

@rebelweb
Last active July 19, 2017 23:47
Show Gist options
  • Save rebelweb/198b0e8a1e6d5f508bde25797f64bf65 to your computer and use it in GitHub Desktop.
Save rebelweb/198b0e8a1e6d5f508bde25797f64bf65 to your computer and use it in GitHub Desktop.
Basic Object
class NotificationType
attr_accessor :id, :load_id
def initialize(id, load_id)
self.id = id
self.load_id = load_id
check_valid_id
end
def description
format(statuses[id], load_id)
end
private
def statuses
['Description A - %s',
'Description B - %s',
'Description C - %s',
'Description D - %s',
'Description E - %s']
end
def check_valid_id
return if id.instance_of?(Integer) && id >= 0 && id <= 9
raise 'Invalid Notification Type Id'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment