Class: Hocon::Impl::Tokens::Comment

Inherits:
Token
  • Object
show all
Defined in:
lib/hocon/impl/tokens.rb

Direct Known Subclasses

DoubleSlashComment, HashComment

Defined Under Namespace

Classes: DoubleSlashComment, HashComment

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(origin, text) ⇒ Comment

Returns a new instance of Comment.



198
199
200
201
# File 'lib/hocon/impl/tokens.rb', line 198

def initialize(origin, text)
  super(TokenType::COMMENT, origin)
  @text = text
end

Instance Attribute Details

#textObject (readonly)

Returns the value of attribute text.



223
224
225
# File 'lib/hocon/impl/tokens.rb', line 223

def text
  @text
end

Instance Method Details

#==(other) ⇒ Object



237
238
239
# File 'lib/hocon/impl/tokens.rb', line 237

def ==(other)
  super(other) && other.text == @text
end

#can_equal(other) ⇒ Object



233
234
235
# File 'lib/hocon/impl/tokens.rb', line 233

def can_equal(other)
  other.is_a?(Comment)
end

#hashObject



241
242
243
244
245
246
# File 'lib/hocon/impl/tokens.rb', line 241

def hash
  hashcode = 41 * (41 + super)
  hashcode = 41 * (hashcode + @text.hash)

  hashcode
end

#to_sObject



225
226
227
228
229
230
231
# File 'lib/hocon/impl/tokens.rb', line 225

def to_s
  sb = StringIO.new
  sb << "'#"
  sb << text
  sb << "' (COMMENT)"
  sb.string
end