Class: Dxf::DesignToolPlanParser
- Inherits:
-
Object
- Object
- Dxf::DesignToolPlanParser
- Defined in:
- lib/dxf/design_tool_plan_parser.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#xml_data ⇒ Object
readonly
Returns the value of attribute xml_data.
-
#xml_doc ⇒ Object
readonly
Returns the value of attribute xml_doc.
Instance Method Summary collapse
- #control ⇒ Object
- #dxf_raw ⇒ Object
- #flooring_type ⇒ Object
-
#initialize(options = {}) ⇒ DesignToolPlanParser
constructor
A new instance of DesignToolPlanParser.
- #initialize_xml ⇒ Object
- #line_coordonates ⇒ Object
- #project_info ⇒ Object
- #room_type ⇒ Object
- #save_to_file(file_handle) ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ DesignToolPlanParser
Returns a new instance of DesignToolPlanParser.
5 6 7 8 9 |
# File 'lib/dxf/design_tool_plan_parser.rb', line 5 def initialize( = {}) @options = raise "Need a :file_path or a :xml_data argument" if @options[:file_path].nil? and @options[:xml_data].nil? raise "File #{@options[:file_path]} does not exist" if @options[:file_path].present? and !File.exist?(@options[:file_path]) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/dxf/design_tool_plan_parser.rb', line 3 def @options end |
#xml_data ⇒ Object (readonly)
Returns the value of attribute xml_data.
3 4 5 |
# File 'lib/dxf/design_tool_plan_parser.rb', line 3 def xml_data @xml_data end |
#xml_doc ⇒ Object (readonly)
Returns the value of attribute xml_doc.
3 4 5 |
# File 'lib/dxf/design_tool_plan_parser.rb', line 3 def xml_doc @xml_doc end |
Instance Method Details
#control ⇒ Object
47 48 49 |
# File 'lib/dxf/design_tool_plan_parser.rb', line 47 def control xml_doc.at_xpath("//ControlPlacement").content end |
#dxf_raw ⇒ Object
22 23 24 25 26 |
# File 'lib/dxf/design_tool_plan_parser.rb', line 22 def dxf_raw initialize_xml fp = Dxf::FloorPlan.new(to_hash, room_type, flooring_type) fp.dxf end |
#flooring_type ⇒ Object
37 38 39 |
# File 'lib/dxf/design_tool_plan_parser.rb', line 37 def flooring_type xml_doc.at_xpath("//FlooringType").content end |
#initialize_xml ⇒ Object
11 12 13 14 |
# File 'lib/dxf/design_tool_plan_parser.rb', line 11 def initialize_xml @xml_data = [:xml_data] || File.read( [:file_path] ) @xml_doc = Nokogiri::XML( @xml_data ) end |
#line_coordonates ⇒ Object
41 42 43 44 45 |
# File 'lib/dxf/design_tool_plan_parser.rb', line 41 def line_coordonates # xml_doc.at_xpath("//Project//Room//DrawingInfo//UserFloorPlan//RoomShape").content xml_doc.xpath("//Project//Room//DrawingInfo//UserFloorPlan//RoomShape") # lines = @xml_doc.xpath("//Project//Room//DrawingInfo//UserFloorPlan//RoomShape//Line") end |
#project_info ⇒ Object
51 52 53 |
# File 'lib/dxf/design_tool_plan_parser.rb', line 51 def project_info xml_doc.xpath("//Project" , 'projectid' => 'projectid') end |
#room_type ⇒ Object
33 34 35 |
# File 'lib/dxf/design_tool_plan_parser.rb', line 33 def room_type xml_doc.at_xpath("//RoomType").content end |
#save_to_file(file_handle) ⇒ Object
16 17 18 19 20 |
# File 'lib/dxf/design_tool_plan_parser.rb', line 16 def save_to_file(file_handle) initialize_xml fp = Dxf::FloorPlan.new(to_hash, room_type, flooring_type) file_handle.write(fp.dxf) end |
#to_hash ⇒ Object
28 29 30 31 |
# File 'lib/dxf/design_tool_plan_parser.rb', line 28 def to_hash parser = Nori.new(parser: :nokogiri) parser.parse @xml_data end |