Class: QrForge::Payloads::PlainText

Inherits:
Object
  • Object
show all
Defined in:
lib/qr_forge/payloads/plain_text.rb

Overview

Represents a plain text payload

Examples:

return “Hello, World!”


Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ PlainText

Returns a new instance of PlainText.



9
10
11
# File 'lib/qr_forge/payloads/plain_text.rb', line 9

def initialize(text)
  @text = text
end

Instance Method Details

#to_sObject



13
14
15
# File 'lib/qr_forge/payloads/plain_text.rb', line 13

def to_s
  @text
end

#validate!Object

Validates that the passed data is a string.



19
20
21
22
# File 'lib/qr_forge/payloads/plain_text.rb', line 19

def validate!
  raise PayloadValidationError, "Must be a valid string" unless @text.is_a?(String)
  raise PayloadValidationError, "String cannot be empty" if @text.empty?
end