Class: Logline::Script

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

Defined Under Namespace

Classes: Action, CharacterName, Dialogue, Heading, Paragraph, Transition, Unknown

Constant Summary collapse

@@klass_map =
{'Scene Heading' => Heading, 'Action' => Action, 'Character' => CharacterName, 'Dialogue' => Dialogue, 'Transition' => Transition}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Script



65
66
67
68
69
70
71
# File 'lib/logline.rb', line 65

def initialize(data)
  @doc = Nokogiri::XML(data)
  @paragraphs = doc.xpath('/FinalDraft/Content/Paragraph').collect do |paragraph|
    text = paragraph.css('Text').collect {|t| t.inner_text }.join('')
    (@@klass_map[paragraph.attributes['Type'].to_s] || Unknown).new(text)
  end
end

Instance Attribute Details

#docObject (readonly)

Returns the value of attribute doc.



5
6
7
# File 'lib/logline.rb', line 5

def doc
  @doc
end

#paragraphsObject (readonly)

Returns the value of attribute paragraphs.



6
7
8
# File 'lib/logline.rb', line 6

def paragraphs
  @paragraphs
end

Class Method Details

.from_fdx(path) ⇒ Object



8
9
10
# File 'lib/logline.rb', line 8

def self.from_fdx(path)
  new File.read(path)
end

Instance Method Details

#to_scrippetObject



12
13
14
# File 'lib/logline.rb', line 12

def to_scrippet
  paragraphs.collect {|paragraph| paragraph.to_scrippet }.join("\n")
end