Class: Logline::Script
- Inherits:
-
Object
- Object
- Logline::Script
- 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
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
-
#paragraphs ⇒ Object
readonly
Returns the value of attribute paragraphs.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data) ⇒ Script
constructor
A new instance of Script.
- #to_scrippet ⇒ Object
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
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
5 6 7 |
# File 'lib/logline.rb', line 5 def doc @doc end |
#paragraphs ⇒ Object (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_scrippet ⇒ Object
12 13 14 |
# File 'lib/logline.rb', line 12 def to_scrippet paragraphs.collect {|paragraph| paragraph.to_scrippet }.join("\n") end |