Class: Khaleesi::Page
- Inherits:
-
Object
- Object
- Khaleesi::Page
- Defined in:
- lib/khaleesi/generator.rb
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(page_file, page_variables) ⇒ Page
constructor
A new instance of Page.
- #take_create_time ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(page_file, page_variables) ⇒ Page
Returns a new instance of Page.
586 587 588 589 |
# File 'lib/khaleesi/generator.rb', line 586 def initialize(page_file, page_variables) @page_file = File.(page_file) @page_variables = page_variables end |
Instance Method Details
#<=>(other) ⇒ Object
591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 |
# File 'lib/khaleesi/generator.rb', line 591 def <=> (other) regexp = /^sequence(\p{Blank}?):(\p{Blank}?)(\d+)$/ self_sequence = @page_variables[regexp, 3] if @page_variables o_variables = other.instance_variable_get(:@page_variables) other_sequence = o_variables[regexp, 3] if o_variables # if which one specify sequence, we shall force comparing by sequence. if self_sequence || other_sequence self_sequence = self_sequence.to_i other_sequence = other_sequence.to_i return 1 if self_sequence < other_sequence return 0 if self_sequence == other_sequence return -1 if self_sequence > other_sequence end other_create_time = other.take_create_time self_create_time = take_create_time other_create_time <=> self_create_time end |
#take_create_time ⇒ Object
615 616 617 618 619 |
# File 'lib/khaleesi/generator.rb', line 615 def take_create_time # cache the create time to improve performance while sorting by. return @create_time if @create_time @create_time = Generator.fetch_create_time(@page_file) end |
#to_s ⇒ Object
621 622 623 |
# File 'lib/khaleesi/generator.rb', line 621 def to_s @page_file end |