Class: CronEdit::EntryPlaceholder

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

Overview

When the Crontab object reads in (parse) all lines, placeholder appears where a Crontab entry with an id was detected

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(anId) ⇒ EntryPlaceholder

Returns a new instance of EntryPlaceholder.



390
391
392
# File 'lib/cronedit.rb', line 390

def initialize anId
    @id = anId.to_s
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



379
380
381
# File 'lib/cronedit.rb', line 379

def id
  @id
end

Class Method Details

.Create(aLine) ⇒ Object



380
381
382
383
# File 'lib/cronedit.rb', line 380

def self.Create(aLine)
    id = ScanId aLine
    return id ? EntryPlaceholder.new(id) : nil
end

.GenerateId(anId) ⇒ Object



387
388
389
# File 'lib/cronedit.rb', line 387

def self.GenerateId anId
    "##__#{anId}__"
end

.ScanId(aStr) ⇒ Object



384
385
386
# File 'lib/cronedit.rb', line 384

def self.ScanId aStr
    aStr.scan(/^\#\#__(.*)__/).flatten.first
end

Instance Method Details

#mergedump(anIO, anEntryHash) ⇒ Object

returns used id



395
396
397
398
399
400
401
402
403
404
# File 'lib/cronedit.rb', line 395

def mergedump anIO, anEntryHash
    entry = anEntryHash[@id]
    if entry
        anIO.puts "#{EntryPlaceholder.GenerateId @id}\n"
        anIO.puts "#{entry}\n"
        return @id
    else
        return nil
    end
end